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

#include <concurrency.h>

Inheritance diagram for Channel< ItemT >:
Collaboration diagram for Channel< ItemT >:

Public Member Functions

 Channel ()
 
 ~Channel ()
 
std::vector< ItemT * > * StartEnqueueing ()
 
void AbortEnqueueing ()
 
void CommitEnqueueing ()
 
void PushBack (ItemT *item)
 
ItemT * PopFront ()
 

Private Attributes

std::vector< ItemT * > items_
 
pthread_mutex_t lock_
 
pthread_cond_t cond_populated_
 

Additional Inherited Members

- Private Member Functions inherited from SingleCopy
 SingleCopy ()
 

Detailed Description

template<class ItemT>
class Channel< ItemT >

This file is part of the CernVM File System. A thread-safe, unbounded vector of items that implement a FIFO channel. Uses conditional variables to block when threads try to pop from the empty channel.

Definition at line 31 of file concurrency.h.

Constructor & Destructor Documentation

template<class ItemT>
Channel< ItemT >::Channel ( )
inline

Definition at line 33 of file concurrency.h.

template<class ItemT>
Channel< ItemT >::~Channel ( )
inline

Definition at line 40 of file concurrency.h.

Member Function Documentation

template<class ItemT>
void Channel< ItemT >::AbortEnqueueing ( )
inline

Unlocks the queue. The queue must remain unchanged when this is called.

Definition at line 57 of file concurrency.h.

template<class ItemT>
void Channel< ItemT >::CommitEnqueueing ( )
inline

1 new item was added to the queue. Unlock and signal to reader thread.

Definition at line 65 of file concurrency.h.

template<class ItemT>
ItemT* Channel< ItemT >::PopFront ( )
inline

Remove and return the first element from the queue. Block if tube is empty.

Definition at line 83 of file concurrency.h.

template<class ItemT>
void Channel< ItemT >::PushBack ( ItemT *  item)
inline

Definition at line 72 of file concurrency.h.

template<class ItemT>
std::vector<ItemT *>* Channel< ItemT >::StartEnqueueing ( )
inline

Returns the queue locked and ready for appending 1 item.

Definition at line 48 of file concurrency.h.

Member Data Documentation

template<class ItemT>
pthread_cond_t Channel< ItemT >::cond_populated_
private

Signals if there are items enqueued

Definition at line 104 of file concurrency.h.

template<class ItemT>
std::vector<ItemT *> Channel< ItemT >::items_
private

The locked queue/channel

Definition at line 96 of file concurrency.h.

template<class ItemT>
pthread_mutex_t Channel< ItemT >::lock_
private

Protects all internal state

Definition at line 100 of file concurrency.h.


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