CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FifoChannel< T > Class Template Reference

#include <concurrency.h>

Inheritance diagram for FifoChannel< T >:
Collaboration diagram for FifoChannel< T >:

Public Member Functions

 FifoChannel (const size_t maximal_length, const size_t drainout_threshold)
 
virtual ~FifoChannel ()
 
void Enqueue (const T &data)
 
const T Dequeue ()
 
unsigned int Drop ()
 
size_t GetItemCount () const
 
bool IsEmpty () const
 
size_t GetMaximalItemCount () const
 

Private Attributes

const size_t maximal_queue_length_
 
const size_t queue_drainout_threshold_
 
pthread_mutex_t mutex_
 
pthread_cond_t queue_is_not_empty_
 
pthread_cond_t queue_is_not_full_
 

Detailed Description

template<class T>
class FifoChannel< T >

Asynchronous FIFO channel template Implements a thread safe FIFO queue that handles thread blocking if the queue is full or empty.

Parameters
Tthe data type to be enqueued in the queue

Definition at line 305 of file concurrency.h.

Constructor & Destructor Documentation

template<class T >
FifoChannel< T >::FifoChannel ( const size_t  maximal_length,
const size_t  drainout_threshold 
)

Creates a new FIFO channel.

Parameters
maximal_lengththe maximal number of items that can be enqueued
drainout_thresholdif less than xx elements are in the queue it is considered to be "not full"

Definition at line 180 of file concurrency_impl.h.

Here is the call graph for this function:

template<class T >
FifoChannel< T >::~FifoChannel ( )
virtual

Definition at line 198 of file concurrency_impl.h.

Member Function Documentation

template<class T >
const T FifoChannel< T >::Dequeue ( )

Removes the next element from the channel. If the queue is empty, this will block until another thread enqueues an item into the channel.

Returns
the first item in the channel queue

Definition at line 223 of file concurrency_impl.h.

template<class T >
unsigned int FifoChannel< T >::Drop ( )

Clears all items in the FIFO channel. The cleared items will be lost.

Returns
the number of dropped items

Definition at line 245 of file concurrency_impl.h.

template<class T>
void FifoChannel< T >::Enqueue ( const T &  data)

Adds a new item to the end of the FIFO channel. If the queue is full, this call will block until items were dequeued by another thread allowing the desired insertion.

Parameters
datathe data to be enqueued into the FIFO channel

Definition at line 206 of file concurrency_impl.h.

template<class T >
size_t FifoChannel< T >::GetItemCount ( ) const
inline

Definition at line 261 of file concurrency_impl.h.

template<class T >
size_t FifoChannel< T >::GetMaximalItemCount ( ) const
inline

Definition at line 275 of file concurrency_impl.h.

template<class T >
bool FifoChannel< T >::IsEmpty ( ) const
inline

Definition at line 268 of file concurrency_impl.h.

Member Data Documentation

template<class T>
const size_t FifoChannel< T >::maximal_queue_length_
private

Definition at line 348 of file concurrency.h.

template<class T>
pthread_mutex_t FifoChannel< T >::mutex_
mutableprivate

Definition at line 352 of file concurrency.h.

Referenced by FifoChannel< T >::FifoChannel().

template<class T>
const size_t FifoChannel< T >::queue_drainout_threshold_
private

Definition at line 349 of file concurrency.h.

template<class T>
pthread_cond_t FifoChannel< T >::queue_is_not_empty_
mutableprivate

Definition at line 353 of file concurrency.h.

Referenced by FifoChannel< T >::FifoChannel().

template<class T>
pthread_cond_t FifoChannel< T >::queue_is_not_full_
mutableprivate

Definition at line 354 of file concurrency.h.

Referenced by FifoChannel< T >::FifoChannel().


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