32#include <sptk5/sptk.h>
33#include <sptk5/threads/Semaphore.h>
87 std::scoped_lock lock(m_mutex);
88 m_list.push_front(data);
100 virtual bool pop_front(T& item, std::chrono::milliseconds timeout)
104 std::scoped_lock lock(m_mutex);
107 item = m_list.front();
124 std::scoped_lock lock(m_mutex);
125 m_list.push_back(data);
137 virtual bool pop_back(T& item, std::chrono::milliseconds timeout)
141 std::scoped_lock lock(m_mutex);
144 item = m_list.back();
157 std::scoped_lock lock(m_mutex);
176 std::scoped_lock lock(m_mutex);
177 return m_list.empty();
185 std::scoped_lock lock(m_mutex);
186 return m_list.size();
194 std::scoped_lock lock(m_mutex);
206 std::scoped_lock lock(m_mutex);
207 for (
auto itor = m_list.begin(); itor != m_list.end(); ++itor)
209 if (!callbackFunction(*itor))
218 mutable std::mutex m_mutex;
Generic unnamed semaphore class.
Definition: Semaphore.h:52
bool sleep_for(std::chrono::milliseconds timeout)
Wait until semaphore value is greater than zero, or until timeout interval is passed.
void post()
Post the semaphore.
Definition: SynchronizedList.h:49
virtual bool pop_back(T &item, std::chrono::milliseconds timeout)
Definition: SynchronizedList.h:137
void clear()
Definition: SynchronizedList.h:192
virtual void push_front(const T &data)
Definition: SynchronizedList.h:85
SynchronizedList()=default
size_t size() const
Definition: SynchronizedList.h:183
bool empty() const
Definition: SynchronizedList.h:174
std::function< bool(T &item)> CallbackFunction
Definition: SynchronizedList.h:58
virtual void push_back(const T &data)
Definition: SynchronizedList.h:122
virtual bool pop_front(T &item, std::chrono::milliseconds timeout)
Definition: SynchronizedList.h:100
virtual void wakeup()
Definition: SynchronizedList.h:166
bool each(const CallbackFunction &callbackFunction)
Definition: SynchronizedList.h:204
virtual void remove(T &item)
Definition: SynchronizedList.h:155