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

#include <tube.h>

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

Classes

class  Link
 

Public Member Functions

 Tube ()
 
 Tube (uint64_t limit)
 
 ~Tube ()
 
LinkEnqueueBack (ItemT *item)
 
LinkEnqueueFront (ItemT *item)
 
ItemT * Slice (Link *link)
 
ItemT * PopFront ()
 
ItemT * PopBack ()
 
void Wait ()
 
bool IsEmpty ()
 
uint64_t size ()
 

Private Member Functions

void Init ()
 
ItemT * SliceUnlocked (Link *link)
 
- Private Member Functions inherited from SingleCopy
 SingleCopy ()
 

Private Attributes

uint64_t limit_
 
uint64_t size_
 
Linkhead_
 
pthread_mutex_t lock_
 
pthread_cond_t cond_populated_
 
pthread_cond_t cond_capacious_
 
pthread_cond_t cond_empty_
 

Detailed Description

template<class ItemT>
class Tube< ItemT >

This file is part of the CernVM File System. A thread-safe, doubly linked list of links containing pointers to ItemT. The ItemT elements are not owned by the Tube. FIFO or LIFO semantics. Using Slice(), items at arbitrary locations in the tube can be removed, too.

The layout of the linked list is as follows:


| | –> I$n$ (back) <–> I2 <–> ... <–> I1 (front) <–> HEAD <–

The tube links the steps in the file processing pipeline. It connects multiple producers to multiple consumers and can throttle the producers if a limit for the tube size is set.

Internally, uses conditional variables to block when threads try to pop from the empty tube or insert into the full tube.

Definition at line 39 of file tube.h.

Constructor & Destructor Documentation

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

Definition at line 53 of file tube.h.

template<class ItemT>
Tube< ItemT >::Tube ( uint64_t  limit)
inlineexplicit

Definition at line 54 of file tube.h.

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

Definition at line 57 of file tube.h.

Member Function Documentation

template<class ItemT>
Link* Tube< ItemT >::EnqueueBack ( ItemT *  item)
inline

Push an item to the back of the queue. Block if queue is currently full.

Definition at line 73 of file tube.h.

Referenced by IngestionPipeline::Process(), and ScrubbingPipeline::Process().

Here is the caller graph for this function:

template<class ItemT>
Link* Tube< ItemT >::EnqueueFront ( ItemT *  item)
inline

Push an item to the front of the queue. Block if queue currently full.

Definition at line 93 of file tube.h.

template<class ItemT>
void Tube< ItemT >::Init ( )
inlineprivate

Definition at line 161 of file tube.h.

Referenced by Tube< FileItem >::Tube().

Here is the caller graph for this function:

template<class ItemT>
bool Tube< ItemT >::IsEmpty ( )
inline

Definition at line 150 of file tube.h.

template<class ItemT>
ItemT* Tube< ItemT >::PopBack ( )
inline

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

Definition at line 134 of file tube.h.

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

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

Definition at line 123 of file tube.h.

Referenced by TaskRegister::Process(), and TaskScrubbingCallback::Process().

Here is the caller graph for this function:

template<class ItemT>
uint64_t Tube< ItemT >::size ( )
inline

Definition at line 155 of file tube.h.

template<class ItemT>
ItemT* Tube< ItemT >::Slice ( Link link)
inline

Remove any link from the queue and return its item, including first/last element.

Definition at line 114 of file tube.h.

template<class ItemT>
ItemT* Tube< ItemT >::SliceUnlocked ( Link link)
inlineprivate

Definition at line 176 of file tube.h.

Referenced by Tube< FileItem >::PopBack(), Tube< FileItem >::PopFront(), and Tube< FileItem >::Slice().

Here is the caller graph for this function:

template<class ItemT>
void Tube< ItemT >::Wait ( )
inline

Blocks until the tube is empty

Definition at line 144 of file tube.h.

Referenced by IngestionPipeline::WaitFor(), and ScrubbingPipeline::WaitFor().

Here is the caller graph for this function:

Member Data Documentation

template<class ItemT>
pthread_cond_t Tube< ItemT >::cond_capacious_
private

Signals if there is space to enqueue more items

Definition at line 217 of file tube.h.

Referenced by Tube< FileItem >::EnqueueBack(), Tube< FileItem >::EnqueueFront(), Tube< FileItem >::Init(), Tube< FileItem >::SliceUnlocked(), and Tube< FileItem >::~Tube().

template<class ItemT>
pthread_cond_t Tube< ItemT >::cond_empty_
private

Signals if the queue runs empty

Definition at line 221 of file tube.h.

Referenced by Tube< FileItem >::Init(), Tube< FileItem >::SliceUnlocked(), Tube< FileItem >::Wait(), and Tube< FileItem >::~Tube().

template<class ItemT>
pthread_cond_t Tube< ItemT >::cond_populated_
private
template<class ItemT>
Link* Tube< ItemT >::head_
private
template<class ItemT>
uint64_t Tube< ItemT >::limit_
private

Adding new item blocks as long as limit_ == size_

Definition at line 197 of file tube.h.

Referenced by Tube< FileItem >::EnqueueBack(), and Tube< FileItem >::EnqueueFront().

template<class ItemT>
uint64_t Tube< ItemT >::size_
private

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