|
| | TSQueue ()=default |
| | Default constructor: no external notifier.
|
| | TSQueue (std::function< void()> notifier) |
| | Construct a queue that calls notifier after every successful push, once the queue mutex has been released.
|
| template<typename... E> |
| void | push (E... t) |
| | Push onto the queue.
|
| std::optional< T > | pop () |
| | Pop something off the queue but return nullopt if the queue is empty.
|
| std::optional< T > | waitPop () |
| | Block until an item is available or requestShutdown() is called.
|
| void | pop (std::function< bool(const T &)> callback) |
| | Call the callback for the front of the queue (if anything is there).
|
| bool | empty () const |
| | Is the queue empty?
|
| void | requestShutdown () |
| | Permanently retire the queue: wake every current and future waitPop() with nullopt so consumer threads can exit cleanly.
|
| bool | isShutdown () const |
| | True once requestShutdown() has been called.
|
template<typename T>
class esi::utils::TSQueue< T >
Thread safe queue.
Just wraps std::queue protected with a lock. Long term, we need to avoid copying data. It has a lot of data copies currently.
Push operations notify a built-in condition variable so consumers can block on waitPop() rather than poll. requestShutdown() permanently wakes any waiters with nullopt, which is how owners cleanly retire a drainer thread.
Definition at line 48 of file Utils.h.
Construct a queue that calls notifier after every successful push, once the queue mutex has been released.
Use this to ring an external doorbell (e.g. a server-wide "ports with pending data" set) without making every push site know about it. The notifier is fixed for the lifetime of the queue — there is no setter, because changing it while other threads are pushing would be a data race.
Definition at line 80 of file Utils.h.
References notifier.
Permanently retire the queue: wake every current and future waitPop() with nullopt so consumer threads can exit cleanly.
Pushes after this still enqueue, but no one is expected to be waiting.
Definition at line 151 of file Utils.h.
References cv, qM, and shutdown.