VisionWorks Toolkit Reference

December 18, 2015 | 1.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvxio::ThreadSafeQueue< T > Class Template Reference

Detailed Description

template<typename T>
class nvxio::ThreadSafeQueue< T >

Thread-Safe Queue class.

See also
NVXIO APIs

Definition at line 67 of file ThreadSafeQueue.hpp.

Public Member Functions

void clear ()
 Removes all elements from the queue. More...
 
bool pop (T &item, unsigned int timeout=1)
 Attemps to pop the oldest value from the queue. More...
 
bool push (const T &item, unsigned int timeout=1)
 Attemps to push a new value into the queue. More...
 
 ThreadSafeQueue (std::size_t maxSize)
 Creation of a thread-safe queue with a specified capacity. More...
 

Protected Member Functions

ThreadSafeQueueoperator= (const ThreadSafeQueue &)
 
 ThreadSafeQueue (const ThreadSafeQueue &)
 

Protected Attributes

std::condition_variable condNonEmpty
 
std::condition_variable condNonFull
 
std::size_t maxSize
 
std::mutex mutex
 
std::queue< T > queue
 

Constructor & Destructor Documentation

template<typename T >
nvxio::ThreadSafeQueue< T >::ThreadSafeQueue ( std::size_t  maxSize)
inlineexplicit

Creation of a thread-safe queue with a specified capacity.

Parameters
[in]maxSizeA capacity of a queue.

Definition at line 76 of file ThreadSafeQueue.hpp.

template<typename T >
nvxio::ThreadSafeQueue< T >::ThreadSafeQueue ( const ThreadSafeQueue< T > &  )
protected

Member Function Documentation

template<typename T >
bool nvxio::ThreadSafeQueue< T >::push ( const T &  item,
unsigned int  timeout = 1 
)
inline

Attemps to push a new value into the queue.

Parameters
[in]itemA new value to push into the queue.
[in]timeoutA maximum timeout in ms that the method should be waiting while the queue is full.
Returns
Status of the operation. Returns true in case of a new element has been pushed into the queue. Otherwise the method returns false.

Definition at line 88 of file ThreadSafeQueue.hpp.

References nvxio::ThreadSafeQueue< T >::condNonEmpty, nvxio::ThreadSafeQueue< T >::condNonFull, nvxio::ThreadSafeQueue< T >::maxSize, nvxio::ThreadSafeQueue< T >::mutex, and nvxio::ThreadSafeQueue< T >::queue.

template<typename T >
bool nvxio::ThreadSafeQueue< T >::pop ( T &  item,
unsigned int  timeout = 1 
)
inline

Attemps to pop the oldest value from the queue.

Parameters
[out]itemThe oldest value of the queue. It will not be assinged if the queue is empty.
[in]timeoutA maximum timeout in ms that the method should be waiting while the queue is empty.
Returns
Status of the operation. Returns true in case of the oldest element has been popped from the queue. Otherwise the method returns false.

Definition at line 113 of file ThreadSafeQueue.hpp.

References nvxio::ThreadSafeQueue< T >::condNonEmpty, nvxio::ThreadSafeQueue< T >::condNonFull, nvxio::ThreadSafeQueue< T >::mutex, and nvxio::ThreadSafeQueue< T >::queue.

template<typename T >
void nvxio::ThreadSafeQueue< T >::clear ( )
inline

Removes all elements from the queue.

Definition at line 133 of file ThreadSafeQueue.hpp.

References nvxio::ThreadSafeQueue< T >::condNonFull, nvxio::ThreadSafeQueue< T >::mutex, and nvxio::ThreadSafeQueue< T >::queue.

template<typename T >
ThreadSafeQueue& nvxio::ThreadSafeQueue< T >::operator= ( const ThreadSafeQueue< T > &  )
protected

Field Documentation

template<typename T >
std::queue<T> nvxio::ThreadSafeQueue< T >::queue
protected
template<typename T >
std::size_t nvxio::ThreadSafeQueue< T >::maxSize
protected

Definition at line 145 of file ThreadSafeQueue.hpp.

Referenced by nvxio::ThreadSafeQueue< T >::push().

template<typename T >
std::mutex nvxio::ThreadSafeQueue< T >::mutex
protected
template<typename T >
std::condition_variable nvxio::ThreadSafeQueue< T >::condNonEmpty
protected
template<typename T >
std::condition_variable nvxio::ThreadSafeQueue< T >::condNonFull
protected

The documentation for this class was generated from the following file: