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

#include <util_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 446 of file util_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 235 of file util_concurrency_impl.h.

Here is the call graph for this function:

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

Definition at line 253 of file util_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 278 of file util_concurrency_impl.h.

Referenced by upload::SessionContextBase::Finalize().

Here is the caller graph for this function:

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 300 of file util_concurrency_impl.h.

Referenced by upload::SessionContextBase::Initialize().

Here is the caller graph for this function:

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 261 of file util_concurrency_impl.h.

Referenced by upload::SessionContextBase::Dispatch().

Here is the caller graph for this function:

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

Definition at line 316 of file util_concurrency_impl.h.

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

Definition at line 330 of file util_concurrency_impl.h.

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

Definition at line 323 of file util_concurrency_impl.h.

Referenced by upload::SessionContextBase::Finalize().

Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 489 of file util_concurrency.h.

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

Definition at line 493 of file util_concurrency.h.

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

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

Definition at line 490 of file util_concurrency.h.

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

Definition at line 494 of file util_concurrency.h.

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

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

Definition at line 495 of file util_concurrency.h.

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


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