25 #include <semaphore.h>
32 return reinterpret_cast<sem_t*
>(s) ;
45 G_ASSERT( reinterpret_cast<void*>(
this) == reinterpret_cast<void*>(&m_storage) ) ;
47 if( 0 != ::sem_init( ptr(
this) , shared , initial_value ) )
50 throw Error(
"sem_init" , G::Process::strerror(e) ) ;
56 ::sem_destroy( ptr(
this) ) ;
62 ::sem_post( ptr(
this) ) ;
68 struct timespec ts = { ::time(
nullptr)+timeout , 0 } ;
69 int rc = ::sem_timedwait( ptr(
this) , &ts ) ;
76 ::sem_wait( ptr(
this) ) ;
void decrement()
Decrement-but-block-if-zero operator.
static Semaphore * at(storage_type *)
Syntactic sugar to return an object pointer corresponding to the given storage pointer.
void increment()
Increment operator. Used for mutex unlocking.
A semaphore class with a posix or sysv implementation chosen at build-time.
~Semaphore()
Destroys the semaphore.
Semaphore(unsigned int initial_value=1U)
Constructor for a new anonymous semaphore, typically located inside a shared memory segment using "pl...