Turi Create
4.0
|
Implements a blocking queue useful for producer/consumer models. More...
#include <core/util/blocking_queue.hpp>
Public Member Functions | |
blocking_queue () | |
creates a blocking queue | |
void | enqueue (const T &elem) |
Add an element to the blocking queue. | |
void | enqueue_to_head (const T &elem) |
Add an element to the blocking queue. | |
bool | timed_wait_for_data (size_t ns, size_t immediate_size) |
bool | try_timed_wait_for_data (size_t ns, size_t immediate_size) |
std::pair< T, bool > | dequeue () |
std::pair< T, bool > | try_dequeue () |
bool | empty () |
Returns true if the queue is empty. | |
void | stop_blocking () |
void | start_blocking () |
size_t | size () |
get the current size of the queue | |
bool | wait_until_empty () |
void | broadcast () |
void | broadcast_blocking_empty () |
Implements a blocking queue useful for producer/consumer models.
Definition at line 23 of file blocking_queue.hpp.
|
inline |
Causes any threads currently blocking on a dequeue to wake up and evaluate the state of the queue. If the queue is empty, the threads will return back to sleep immediately. If the queue is destroyed through stop_blocking, all threads will return.
Definition at line 330 of file blocking_queue.hpp.
|
inline |
Causes any threads blocking on "wait_until_empty()" to wake up and evaluate the state of the queue. If the queue is not empty, the threads will return back to sleep immediately. If the queue is empty, all threads will return.
Definition at line 344 of file blocking_queue.hpp.
|
inline |
Blocks until an element is available in the queue or until stop_blocking() is called. The return value is a pair of <T value, bool success> If "success" if set, then "value" is valid and is an element popped from the queue. If "success" is false, stop_blocking() was called and the queue has been destroyed.
Definition at line 216 of file blocking_queue.hpp.
|
inline |
Resumes operation of the blocking_queue. Future calls to dequeue will proceed as normal.
Definition at line 292 of file blocking_queue.hpp.
|
inline |
Wakes up all threads waiting on the queue whether or not an element is available. Once this function is called, all existing and future dequeue operations will return with failure. Note that there could be elements remaining in the queue after stop_blocking() is called.
Definition at line 280 of file blocking_queue.hpp.
|
inline |
Returns immediately of queue size is >= immedeiate_size Otherwise, it will poll over 'ns' nanoseconds or on a signal until queue is not empty.
Definition at line 141 of file blocking_queue.hpp.
|
inline |
Returns an element if the queue has an entry. returns [item, false] otherwise.
Definition at line 245 of file blocking_queue.hpp.
|
inline |
Returns immediately of queue size is >= immedeiate_size Otherwise, it will poll over 'ns' nanoseconds or on a signal until queue is not empty.
Definition at line 165 of file blocking_queue.hpp.
|
inline |
The conceptual "reverse" of dequeue(). This function will block until the queue becomes empty, or until stop_blocking() is called. Returns true on success. Returns false if the queue is no longer alive
Definition at line 310 of file blocking_queue.hpp.