rippled
|
Generic thread-safe queue with an optional maximum size Note, we can't use a lockfree queue here, since we need the ability to wait for an element to be added or removed from the queue. More...
Public Member Functions | |
ThreadSafeQueue (uint32_t maxSize) | |
ThreadSafeQueue ()=default | |
Create a queue with no maximum size. More... | |
void | push (T const &elt) |
void | push (T &&elt) |
T | pop () |
Private Attributes | |
std::queue< T > | queue_ |
std::mutex | m_ |
std::condition_variable | cv_ |
std::optional< uint32_t > | maxSize_ |
Generic thread-safe queue with an optional maximum size Note, we can't use a lockfree queue here, since we need the ability to wait for an element to be added or removed from the queue.
These waits are blocking calls.
Definition at line 115 of file ETLHelpers.h.
|
explicit |
maxSize | maximum size of the queue. Calls that would cause the queue to exceed this size will block until free space is available |
Definition at line 126 of file ETLHelpers.h.
|
default |
Create a queue with no maximum size.
void ripple::ThreadSafeQueue< T >::push | ( | T const & | elt | ) |
elt | element to push onto queue if maxSize is set, this method will block until free space is available |
Definition at line 136 of file ETLHelpers.h.
void ripple::ThreadSafeQueue< T >::push | ( | T && | elt | ) |
elt | element to push onto queue. elt is moved from if maxSize is set, this method will block until free space is available |
Definition at line 149 of file ETLHelpers.h.
T ripple::ThreadSafeQueue< T >::pop | ( | ) |
Definition at line 161 of file ETLHelpers.h.
|
private |
Definition at line 117 of file ETLHelpers.h.
|
mutableprivate |
Definition at line 119 of file ETLHelpers.h.
|
private |
Definition at line 120 of file ETLHelpers.h.
|
private |
Definition at line 121 of file ETLHelpers.h.