CernVM-FS  2.12.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 * TryPopFront ()
 
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.

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

Here is the caller graph for this function:

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

Definition at line 176 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 165 of file tube.h.

Referenced by upload::SessionContextBase::Finalize(), and upload::SessionContextBase::Initialize().

Here is the caller graph for this function:

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 149 of file tube.h.

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

Here is the caller graph for this function:

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 170 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 191 of file tube.h.

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

Here is the caller graph for this function:

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

Remove and return the first element from the queue if there is any. Equivalent to an antomic ItemT item = NULL; if (!IsEmpty()) item = PopFront();

Definition at line 137 of file tube.h.

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

Blocks until the tube is empty

Definition at line 159 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 232 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 236 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 212 of file tube.h.

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


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