![]() |
PIP 5.6.1
Platform-Independent Primitives
|
Thread-safe queue that supports blocking operations - waits for space when storing and waits for element when retrieving. More...
#include <piblockingqueue.h>

Public Member Functions | |
| PIBlockingQueue (size_t capacity=SIZE_MAX, PIConditionVariable *cond_var_add=new PIConditionVariable(), PIConditionVariable *cond_var_rem=new PIConditionVariable()) | |
| Constructs queue with capacity capacity. More... | |
| PIBlockingQueue (const PIDeque< T > &other) | |
| Constructs queue from snapshot of other without synchronizing access to the source deque. | |
| PIBlockingQueue (PIBlockingQueue< T > &other) | |
| Constructs queue by copying another blocking queue while locking both queues. | |
| ~PIBlockingQueue () | |
| Destroys queue and owned condition variables. | |
| PIBlockingQueue< T > & | put (const T &v) |
| Appends v, waiting indefinitely until space becomes available when the queue is full. | |
| PIBlockingQueue< T > & | enqueue (const T &v) |
| Alias for put(). | |
| bool | offer (const T &v, PISystemTime timeout={}) |
| Tries to append v. More... | |
| T | take () |
| Removes and returns the front element, waiting indefinitely until one becomes available. | |
| T | dequeue () |
| Alias for take(). | |
| T | poll (PISystemTime timeout={}, const T &defaultVal=T(), bool *isOk=nullptr) |
| Tries to remove and return the front element. More... | |
| size_t | capacity () |
| Returns configured capacity limit. More... | |
| size_t | remainingCapacity () |
| Returns how many more elements can be inserted without blocking at the moment of the call. | |
| size_t | size () |
| Returns current number of queued elements. | |
| size_t | drainTo (PIDeque< T > &other, size_t maxCount=SIZE_MAX) |
| Moves up to maxCount currently available elements into deque other without waiting. | |
| size_t | drainTo (PIBlockingQueue< T > &other, size_t maxCount=SIZE_MAX) |
| Moves up to maxCount currently available elements into blocking queue other without waiting. More... | |
Thread-safe queue that supports blocking operations - waits for space when storing and waits for element when retrieving.
|
inlineexplicit |
Constructs queue with capacity capacity.
Passed condition variables become owned by the queue and are deleted with it.
|
inline |
Tries to append v.
With null timeout this method checks capacity once and returns immediately.
|
inline |
Tries to remove and return the front element.
With null timeout this method checks once and returns defaultVal immediately if the queue is empty. If isOk is not null, it is set to true on successful retrieval.
|
inline |
Returns configured capacity limit.
For the default unbounded queue this value is SIZE_MAX.
|
inline |
Moves up to maxCount currently available elements into blocking queue other without waiting.
The actual count is also limited by the remaining capacity of other.