![]() |
HTGS
v2.0
The Hybrid Task Graph Scheduler
|
Creates a thread-safe queue that will wait when no data is available and can block if the queue is full. More...
#include <htgs/core/queue/BlockingQueue.hpp>
Public Member Functions | |
BlockingQueue () | |
Creates a blocking queue that will only block a data requester when the queue is empty. | |
BlockingQueue (size_t qSize) | |
Creates a blocking queue that will block a data requester when the queue is empty or full. More... | |
~BlockingQueue () | |
Destructor. | |
size_t | remainingCapacity () |
Gets the remaining capacity of the queue based on the queueSize. More... | |
bool | isEmpty () |
Gets whether the queue is empty or not. More... | |
size_t | size () |
Gets the number of elements in the queue. More... | |
T | remove () |
Removes an element from the queue. More... | |
void | Enqueue (T const &value) |
Adds an element into the queue. More... | |
T | Dequeue () |
Removes an element from the queue. More... | |
T | poll (size_t timeout) |
Polls for data given the specified timeout time in microseconds. More... | |
Private Attributes | |
size_t | queueSize |
The maximum size of the queue, set to -1 for infinite size. | |
std::queue< T > | queue |
The FIFO queue. | |
std::mutex | mutex |
The mutex to ensure thread safety. | |
std::condition_variable | condition |
The condition variable used for waking up waiting threads. | |
Creates a thread-safe queue that will wait when no data is available and can block if the queue is full.
If the size of the queue is specified to be less than 0 (default constructor), then the queue will not block if the queue is full.
|
inline |
Creates a blocking queue that will block a data requester when the queue is empty or full.
qSize |
|
inline |
Removes an element from the queue.
|
inline |
Adds an element into the queue.
value | the element to be added |
|
inline |
Gets whether the queue is empty or not.
TRUE | if the queue is empty |
FALSE | if the queue is not empty |
|
inline |
Polls for data given the specified timeout time in microseconds.
timeout | the timeout time in microseconds |
data | if data exists prior to the timeout time |
nullptr | if no data exists after the timeout time expires |
|
inline |
Gets the remaining capacity of the queue based on the queueSize.
This function should only be used if the queueSize > 0
|
inline |
Removes an element from the queue.
|
inline |
Gets the number of elements in the queue.