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

#include <util_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++ ()
 
operator++ (int)
 
operator-- ()
 
operator-- (int)
 
 operator T () 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 209 of file util_concurrency.h.

Constructor & Destructor Documentation

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

Definition at line 211 of file util_concurrency.h.

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

Definition at line 214 of file util_concurrency.h.

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

Definition at line 222 of file util_concurrency.h.

Member Function Documentation

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

Definition at line 231 of file util_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 113 of file util_concurrency_impl.h.

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

Definition at line 245 of file util_concurrency.h.

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

Definition at line 224 of file util_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 103 of file util_concurrency_impl.h.

Here is the call graph for this function:

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

Definition at line 246 of file util_concurrency.h.

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

Definition at line 253 of file util_concurrency.h.

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

Definition at line 248 of file util_concurrency.h.

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

Definition at line 249 of file util_concurrency.h.

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

Definition at line 250 of file util_concurrency.h.

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

Definition at line 251 of file util_concurrency.h.

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

Definition at line 258 of file util_concurrency.h.

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

Definition at line 76 of file util_concurrency_impl.h.

Here is the call graph for this function:

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

Definition at line 94 of file util_concurrency_impl.h.

Here is the call graph for this function:

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

Definition at line 237 of file util_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 277 of file util_concurrency.h.

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

Definition at line 278 of file util_concurrency.h.

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

Definition at line 274 of file util_concurrency.h.

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

Definition at line 276 of file util_concurrency.h.

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

Definition at line 273 of file util_concurrency.h.


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