CernVM-FS
2.12.0
|
#include <tube.h>
Classes | |
class | Link |
Public Member Functions | |
Tube () | |
Tube (uint64_t limit) | |
~Tube () | |
Link * | EnqueueBack (ItemT *item) |
Link * | EnqueueFront (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_ |
Link * | head_ |
pthread_mutex_t | lock_ |
pthread_cond_t | cond_populated_ |
pthread_cond_t | cond_capacious_ |
pthread_cond_t | cond_empty_ |
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.
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().
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().
|
inlineprivate |
Definition at line 176 of file tube.h.
Referenced by Tube< FileItem >::Tube().
|
inline |
Definition at line 165 of file tube.h.
Referenced by upload::SessionContextBase::Finalize(), and upload::SessionContextBase::Initialize().
|
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().
|
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().
|
inline |
Definition at line 191 of file tube.h.
Referenced by Tube< FileItem >::PopBack(), Tube< FileItem >::PopFront(), Tube< FileItem >::Slice(), and Tube< FileItem >::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();
|
inline |
Blocks until the tube is empty
Definition at line 159 of file tube.h.
Referenced by IngestionPipeline::WaitFor(), and ScrubbingPipeline::WaitFor().
|
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().
|
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().
|
private |
Signals if there are items enqueued
Definition at line 228 of file tube.h.
Referenced by Tube< FileItem >::EnqueueBack(), Tube< FileItem >::EnqueueFront(), Tube< FileItem >::Init(), Tube< FileItem >::PopBack(), Tube< FileItem >::PopFront(), and Tube< FileItem >::~Tube().
Sentinel element in front of the first (front) element
Definition at line 220 of file tube.h.
Referenced by Tube< FileItem >::EnqueueBack(), Tube< FileItem >::EnqueueFront(), Tube< FileItem >::Init(), Tube< FileItem >::PopBack(), Tube< FileItem >::PopFront(), Tube< FileItem >::SliceUnlocked(), Tube< FileItem >::TryPopFront(), and Tube< FileItem >::~Tube().
|
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().
|
private |
Protects all internal state
Definition at line 224 of file tube.h.
Referenced by Tube< FileItem >::EnqueueBack(), Tube< FileItem >::EnqueueFront(), Tube< FileItem >::Init(), Tube< FileItem >::IsEmpty(), Tube< FileItem >::PopBack(), Tube< FileItem >::PopFront(), Tube< FileItem >::size(), Tube< FileItem >::Slice(), Tube< FileItem >::TryPopFront(), Tube< FileItem >::Wait(), and Tube< FileItem >::~Tube().
|
private |
The current number of links in the list
Definition at line 216 of file tube.h.
Referenced by Tube< FileItem >::EnqueueBack(), Tube< FileItem >::EnqueueFront(), Tube< FileItem >::IsEmpty(), Tube< FileItem >::PopBack(), Tube< FileItem >::PopFront(), Tube< FileItem >::size(), Tube< FileItem >::SliceUnlocked(), Tube< FileItem >::TryPopFront(), and Tube< FileItem >::Wait().