PIP 5.5.3
Platform-Independent Primitives
Открытые члены | Полный список членов класса
Шаблон класса PIBlockingQueue< T >

A Queue that supports operations that wait for the queue to become non-empty when retrieving an element, and wait for space to become available in the queue when storing an element. Подробнее...

#include <piblockingqueue.h>

Граф наследования:PIBlockingQueue< T >:
Inheritance graph
[см. легенду]

Открытые члены

 PIBlockingQueue (size_t capacity=SIZE_MAX, PIConditionVariable *cond_var_add=new PIConditionVariable(), PIConditionVariable *cond_var_rem=new PIConditionVariable())
 Constructor.
 
 PIBlockingQueue (const PIDeque< T > &other)
 Copy constructor. Initialize queue with copy of other queue elements. Not thread-safe for other queue.
 
 PIBlockingQueue (PIBlockingQueue< T > &other)
 Thread-safe copy constructor. Initialize queue with copy of other queue elements.
 
PIBlockingQueue< T > & put (const T &v)
 Inserts the specified element into this queue, waiting if necessary for space to become available. Подробнее...
 
bool offer (const T &v, PISystemTime timeout={})
 Inserts the specified element at the end of this queue if it is possible to do so immediately without exceeding the queue's capacity, returning true upon success and false if this queue is full. Подробнее...
 
take ()
 Retrieves and removes the head of this queue, waiting if necessary until an element becomes available. Подробнее...
 
poll (PISystemTime timeout={}, const T &defaultVal=T(), bool *isOk=nullptr)
 Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available. Подробнее...
 
size_t capacity ()
 Returns the number of elements that this queue can ideally (in the absence of memory or resource constraints) contains. This is always equal to the initial capacity of this queue less the current size of this queue. Подробнее...
 
size_t remainingCapacity ()
 Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept. This is always equal to the initial capacity of this queue less the current size of this queue. Подробнее...
 
size_t size ()
 Returns the number of elements in this collection.
 
size_t drainTo (PIDeque< T > &other, size_t maxCount=SIZE_MAX)
 Removes all available elements from this queue and adds them to other given queue.
 
size_t drainTo (PIBlockingQueue< T > &other, size_t maxCount=SIZE_MAX)
 Removes all available elements from this queue and adds them to other given queue.
 

Подробное описание

template<typename T>
class PIBlockingQueue< T >

A Queue that supports operations that wait for the queue to become non-empty when retrieving an element, and wait for space to become available in the queue when storing an element.

Методы

◆ put()

template<typename T >
PIBlockingQueue< T > & PIBlockingQueue< T >::put ( const T &  v)
inline

Inserts the specified element into this queue, waiting if necessary for space to become available.

Аргументы
vthe element to add

◆ offer()

template<typename T >
bool PIBlockingQueue< T >::offer ( const T &  v,
PISystemTime  timeout = {} 
)
inline

Inserts the specified element at the end of this queue if it is possible to do so immediately without exceeding the queue's capacity, returning true upon success and false if this queue is full.

Аргументы
vthe element to add
timeoutthe timeout waiting for inserting if que is full, if timeout is null, then returns immediately
Возвращает
true if the element was added to this queue, else false

◆ take()

template<typename T >
T PIBlockingQueue< T >::take ( )
inline

Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.

Возвращает
the head of this queue

◆ poll()

template<typename T >
T PIBlockingQueue< T >::poll ( PISystemTime  timeout = {},
const T &  defaultVal = T(),
bool *  isOk = nullptr 
)
inline

Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.

Аргументы
timeouthow long to wait before giving up
defaultValvalue, which returns if the specified waiting time elapses before an element is available
isOkflag, which indicates result of method execution. It will be set to false if timeout, or true if return value is retrieved value
Возвращает
the head of this queue, or defaultVal if the specified waiting time elapses before an element is available

◆ capacity()

template<typename T >
size_t PIBlockingQueue< T >::capacity ( )
inline

Returns the number of elements that this queue can ideally (in the absence of memory or resource constraints) contains. This is always equal to the initial capacity of this queue less the current size of this queue.

Возвращает
the capacity

◆ remainingCapacity()

template<typename T >
size_t PIBlockingQueue< T >::remainingCapacity ( )
inline

Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept. This is always equal to the initial capacity of this queue less the current size of this queue.

Возвращает
the remaining capacity