Skip to content

Commit 4863888

Browse files
committed
Implement non-blocking Sink.
1 parent 63553a8 commit 4863888

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Diff for: src/Sink.hpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,29 @@ class SinkBase
4343
template<typename T>
4444
class SinkNonBlocking : public SinkBase<T>
4545
{
46-
/* TODO - Do we really need this? */
46+
public:
47+
48+
SinkNonBlocking();
49+
virtual ~SinkNonBlocking() { }
50+
51+
virtual T read() override
52+
{
53+
_mutex.lock();
54+
return _data;
55+
_mutex.unlock();
56+
}
57+
virtual void inject(T const & value) override
58+
{
59+
_mutex.lock();
60+
_data = value;
61+
_mutex.unlock();
62+
}
63+
64+
private:
65+
66+
T _data;
67+
rtos::Mutex _mutex;
68+
4769
};
4870

4971
template<typename T>

0 commit comments

Comments
 (0)