Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Semaphore Class Reference

Detailed Description

Definition at line 25 of file semaphore.hpp.

#include <semaphore.hpp>

Public Member Functions

 Semaphore (size_t init_value=0)
 construct semaphore More...
 
 Semaphore (const Semaphore &)=delete
 non-copyable: delete copy-constructor More...
 
 Semaphore (Semaphore &&s)
 move-constructor: just move the value More...
 
Semaphoreoperator= (const Semaphore &)=delete
 non-copyable: delete assignment operator More...
 
Semaphoreoperator= (Semaphore &&s)
 move-assignment: just move the value More...
 
size_t signal ()
 
size_t signal (size_t delta)
 
size_t value () const
 return the current value – should only be used for debugging. More...
 
size_t wait ()
 

Private Attributes

std::condition_variable cv_
 condition variable More...
 
std::mutex mutex_
 mutex for condition variable More...
 
size_t value_
 value of the semaphore More...
 

Constructor & Destructor Documentation

Semaphore ( size_t  init_value = 0)
inlineexplicit

construct semaphore

Definition at line 29 of file semaphore.hpp.

Semaphore ( const Semaphore )
delete

non-copyable: delete copy-constructor

Semaphore ( Semaphore &&  s)
inline

move-constructor: just move the value

Definition at line 37 of file semaphore.hpp.

Member Function Documentation

Semaphore& operator= ( const Semaphore )
delete

non-copyable: delete assignment operator

Semaphore& operator= ( Semaphore &&  s)
inline

move-assignment: just move the value

Definition at line 39 of file semaphore.hpp.

References Semaphore::value_.

size_t signal ( size_t  delta)
inline

function increments the semaphore and signals any threads that are blocked waiting a change in the semaphore

Definition at line 51 of file semaphore.hpp.

References Semaphore::cv_, examples::select::delta, Semaphore::mutex_, and Semaphore::value_.

size_t value ( ) const
inline

return the current value – should only be used for debugging.

Definition at line 67 of file semaphore.hpp.

References Semaphore::value_.

Referenced by MixStreamData::Close().

Member Data Documentation

std::condition_variable cv_
private

condition variable

Definition at line 77 of file semaphore.hpp.

Referenced by Semaphore::signal(), and Semaphore::wait().

std::mutex mutex_
private

mutex for condition variable

Definition at line 74 of file semaphore.hpp.

Referenced by Semaphore::signal(), and Semaphore::wait().

size_t value_
private

value of the semaphore

Definition at line 71 of file semaphore.hpp.

Referenced by Semaphore::operator=(), Semaphore::signal(), Semaphore::value(), and Semaphore::wait().


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