Skip to content

Commit

Permalink
Extract implemention of SinkNonBlocking member functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
aentinger committed Oct 12, 2021
1 parent 4863888 commit de2a0d4
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/Sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,12 @@ class SinkNonBlocking : public SinkBase<T>
{
public:

SinkNonBlocking();
SinkNonBlocking() { }
virtual ~SinkNonBlocking() { }

virtual T read() override
{
_mutex.lock();
return _data;
_mutex.unlock();
}
virtual void inject(T const & value) override
{
_mutex.lock();
_data = value;
_mutex.unlock();
}
virtual T read() override;
virtual void inject(T const & value) override;


private:

Expand Down Expand Up @@ -90,6 +81,26 @@ class SinkBlocking : public SinkBase<T>

};

/**************************************************************************************
* PUBLIC MEMBER FUNCTIONS - SinkNonBlocking
**************************************************************************************/

template<typename T>
T SinkNonBlocking<T>::read()
{
_mutex.lock();
return _data;
_mutex.unlock();
}

template<typename T>
void SinkNonBlocking<T>::inject(T const & value)
{
_mutex.lock();
_data = value;
_mutex.unlock();
}

/**************************************************************************************
* PUBLIC MEMBER FUNCTIONS - SinkBlocking
**************************************************************************************/
Expand Down

0 comments on commit de2a0d4

Please sign in to comment.