libzypp 17.37.17
|
#include <zypp-core/zyppng/thread/asyncqueue.h>
Public Types | |
using | Ptr = std::shared_ptr<AsyncQueue> |
Public Member Functions | |
AsyncQueue (const AsyncQueue &)=delete | |
AsyncQueue & | operator= (const AsyncQueue &)=delete |
template<typename T = Message> | |
void | pushUnlocked (T &&value) |
template<typename T = Message> | |
void | push (T &&value) |
Message | pop () |
std::optional< Message > | tryPop () |
std::optional< Message > | tryPopUnlocked () |
void | lock () |
void | unlock () |
void | notify () |
Public Member Functions inherited from zyppng::AsyncQueueBase | |
virtual | ~AsyncQueueBase () |
void | addWatch (AsyncQueueWatch &watch) |
void | removeWatch (AsyncQueueWatch &watch) |
void | notifyWatches () |
Static Public Member Functions | |
static Ptr | create () |
Private Member Functions | |
AsyncQueue ()=default |
Private Attributes | |
std::queue< Message > | _messages |
std::mutex | _mut |
std::condition_variable | _cv |
AsyncQueue provides a thread safe way to send messages between threads. Using this class makes only sense for multithreaded applications.
Definition at line 43 of file asyncqueue.h.
using zyppng::AsyncQueue< Message >::Ptr = std::shared_ptr<AsyncQueue> |
Definition at line 47 of file asyncqueue.h.
|
delete |
|
privatedefault |
|
inlinestatic |
Definition at line 49 of file asyncqueue.h.
|
delete |
|
inline |
Pushes a new message into the queue, make sure to manually acqiure the lock before calling this function and notify after unlocking it again. This function should be used when multiple messages should be pushed into the queue before notifying the threads.
Definition at line 64 of file asyncqueue.h.
|
inline |
Pushes a new message into the queue and notify all waiting threads that there is new data available.
Definition at line 73 of file asyncqueue.h.
|
inline |
Pops the first message from the queue, blocking until there is data available.
Definition at line 84 of file asyncqueue.h.
|
inline |
Tries to pop the first element from the queue, if no data is available returns a empty std::optional instead of blocking.
Definition at line 96 of file asyncqueue.h.
|
inline |
Same as tryPop but does not lock the mutex, make sure to acquire the lock before calling this function.
Definition at line 105 of file asyncqueue.h.
|
inline |
Locks the internal mutex, use std::lock_guard instead of manually calling lock and unlock.
Definition at line 118 of file asyncqueue.h.
|
inline |
Unlocks the internal mutex, use std::lock_guard instead of manually calling lock and unlock.
Definition at line 126 of file asyncqueue.h.
|
inline |
Notifies all waiting threads and registered AsyncQueueWatch instances that new data is available.
Definition at line 134 of file asyncqueue.h.
|
private |
Definition at line 141 of file asyncqueue.h.
|
private |
Definition at line 142 of file asyncqueue.h.
|
private |
Definition at line 143 of file asyncqueue.h.