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

#include <concurrency.h>

Inheritance diagram for SynchronizingCounter< T >:
Collaboration diagram for SynchronizingCounter< T >:

Public Member Functions

 SynchronizingCounter ()
 
 SynchronizingCounter (const T maximal_value)
 
 ~SynchronizingCounter ()
 
Increment ()
 
Decrement ()
 
void WaitForZero () const
 
bool HasMaximalValue () const
 
maximal_value () const
 
operator++ ()
 
const T operator++ (int)
 
operator-- ()
 
const T operator-- (int)
 
Get () const
 
SynchronizingCounter< T > & operator= (const T &other)
 

Protected Member Functions

void SetValueUnprotected (const T new_value)
 
void WaitForFreeSlotUnprotected ()
 

Private Member Functions

void Initialize ()
 
void Destroy ()
 
- Private Member Functions inherited from SingleCopy
 SingleCopy ()
 

Private Attributes

value_
 
const T maximal_value_
 
pthread_mutex_t mutex_
 
pthread_cond_t became_zero_
 
pthread_cond_t free_slot_
 

Detailed Description

template<typename T>
class SynchronizingCounter< T >

This counter can be counted up and down using the usual increment/decrement operators. It allows threads to wait for it to become zero as well as to block when a specified maximal value would be exceeded by an increment.

Note: If a maximal value is specified on creation, the SynchronizingCounter is assumed to never leave the interval [0, maximal_value]! Otherwise the numerical limits of the specified template parameter define this interval and an increment never blocks.

Caveat: This implementation uses a simple mutex mechanism and therefore might become a scalability bottle neck!

Definition at line 68 of file concurrency.h.

Constructor & Destructor Documentation

template<typename T>
SynchronizingCounter< T >::SynchronizingCounter ( )
inline

Definition at line 70 of file concurrency.h.

template<typename T>
SynchronizingCounter< T >::SynchronizingCounter ( const T  maximal_value)
inlineexplicit

Definition at line 73 of file concurrency.h.

template<typename T>
SynchronizingCounter< T >::~SynchronizingCounter ( )
inline

Definition at line 81 of file concurrency.h.

Member Function Documentation

template<typename T>
T SynchronizingCounter< T >::Decrement ( )
inline

Definition at line 90 of file concurrency.h.

Referenced by s3fanout::S3FanoutManager::MainUpload().

Here is the caller graph for this function:

template<typename T >
void SynchronizingCounter< T >::Destroy ( )
private

Definition at line 58 of file concurrency_impl.h.

template<typename T>
T SynchronizingCounter< T >::Get ( ) const
inline

Definition at line 112 of file concurrency.h.

Referenced by s3fanout::S3FanoutManager::CallbackCurlSocket().

Here is the caller graph for this function:

template<typename T>
bool SynchronizingCounter< T >::HasMaximalValue ( ) const
inline

Definition at line 104 of file concurrency.h.

template<typename T>
T SynchronizingCounter< T >::Increment ( )
inline

Definition at line 83 of file concurrency.h.

Referenced by s3fanout::S3FanoutManager::PushNewJob().

Here is the caller graph for this function:

template<typename T >
void SynchronizingCounter< T >::Initialize ( )
private

Definition at line 48 of file concurrency_impl.h.

Here is the call graph for this function:

template<typename T>
T SynchronizingCounter< T >::maximal_value ( ) const
inline

Definition at line 105 of file concurrency.h.

template<typename T>
T SynchronizingCounter< T >::operator++ ( )
inline

Definition at line 107 of file concurrency.h.

template<typename T>
const T SynchronizingCounter< T >::operator++ ( int  )
inline

Definition at line 108 of file concurrency.h.

template<typename T>
T SynchronizingCounter< T >::operator-- ( )
inline

Definition at line 109 of file concurrency.h.

template<typename T>
const T SynchronizingCounter< T >::operator-- ( int  )
inline

Definition at line 110 of file concurrency.h.

template<typename T>
SynchronizingCounter<T>& SynchronizingCounter< T >::operator= ( const T &  other)
inline

Definition at line 117 of file concurrency.h.

template<typename T>
void SynchronizingCounter< T >::SetValueUnprotected ( const T  new_value)
protected

This file is part of the CernVM File System.

Definition at line 21 of file concurrency_impl.h.

Here is the call graph for this function:

template<typename T >
void SynchronizingCounter< T >::WaitForFreeSlotUnprotected ( )
protected

Definition at line 39 of file concurrency_impl.h.

Here is the call graph for this function:

template<typename T>
void SynchronizingCounter< T >::WaitForZero ( ) const
inline

Definition at line 96 of file concurrency.h.

Referenced by upload::AbstractUploader::WaitForUpload().

Here is the caller graph for this function:

Member Data Documentation

template<typename T>
pthread_cond_t SynchronizingCounter< T >::became_zero_
mutableprivate

Definition at line 136 of file concurrency.h.

template<typename T>
pthread_cond_t SynchronizingCounter< T >::free_slot_
private

Definition at line 137 of file concurrency.h.

template<typename T>
const T SynchronizingCounter< T >::maximal_value_
private

Definition at line 133 of file concurrency.h.

template<typename T>
pthread_mutex_t SynchronizingCounter< T >::mutex_
mutableprivate

Definition at line 135 of file concurrency.h.

template<typename T>
T SynchronizingCounter< T >::value_
private

Definition at line 132 of file concurrency.h.


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