#include <SynchronizedList.h>
Public Types | |
using | CallbackFunction = std::function< bool(T &item)> |
Public Member Functions | |
SynchronizedList ()=default | |
SynchronizedList (const SynchronizedList &)=delete | |
SynchronizedList (SynchronizedList &&) noexcept=default | |
SynchronizedList & | operator= (const SynchronizedList &)=delete |
SynchronizedList & | operator= (SynchronizedList &&) noexcept=default |
virtual | ~SynchronizedList ()=default |
virtual void | push_front (const T &data) |
virtual bool | pop_front (T &item, std::chrono::milliseconds timeout) |
virtual void | push_back (const T &data) |
virtual bool | pop_back (T &item, std::chrono::milliseconds timeout) |
virtual void | remove (T &item) |
virtual void | wakeup () |
bool | empty () const |
size_t | size () const |
void | clear () |
bool | each (const CallbackFunction &callbackFunction) |
Synchronized template list
Simple thread-safe list
using sptk::SynchronizedList< T >::CallbackFunction = std::function<bool(T& item)> |
List callback function used in each() method.
Iterates through list until false is returned.
item | T&, List item |
data | void*, Optional function-specific data |
|
default |
Default constructor
|
virtualdefault |
Destructor
|
inline |
Removes all items from the list
|
inline |
Calls for every list until false is returned
callbackFunction | Callback function that is executed for list items |
data | Function-specific data |
|
inline |
Returns true if the list is empty
|
inlinevirtual |
Pops a data item from the list back
If list is empty then waits until timeout occurs. Returns false if timeout occurs.
item | T&, A list item (output) |
timeout | std::chrono::milliseconds, Operation timeout |
References sptk::Semaphore::sleep_for().
|
inlinevirtual |
Pops a data item from the list front
If list is empty then waits until timeout milliseconds occurs. Returns false if timeout occurs.
item | T&, A list item (output) |
timeout | std::chrono::milliseconds, Operation timeout |
References sptk::Semaphore::sleep_for().
|
inlinevirtual |
Pushes a data item to the list back
Automatically posts internal semaphore to indicate list item availability.
data | const T&, A data item |
References sptk::Semaphore::post().
|
inlinevirtual |
Pushes a data item to the list front
Automatically posts internal semaphore to indicate list item availability.
data | const T&, A data item |
References sptk::Semaphore::post().
|
inlinevirtual |
Removes all elements with the specific value from the list
|
inline |
Returns number of items in the list
|
inlinevirtual |
Wakes up list semaphore to interrupt waiting
Any waiting pop() operation immediately returns false.
References sptk::Semaphore::post().