Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::interprocess::interprocess_semaphore Class Reference

Wraps a interprocess_semaphore that can be placed in shared memory and can be shared between processes. More...

#include <interprocess_semaphore.hpp>

Public Member Functions

interprocess_semaphore (unsigned int initialCount)
 Creates a interprocess_semaphore with the given initial count. More...
 
 ~interprocess_semaphore ()
 Destroys the interprocess_semaphore. More...
 
void post ()
 Increments the interprocess_semaphore count. More...
 
void wait ()
 Decrements the interprocess_semaphore. More...
 
bool try_wait ()
 Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true. More...
 
bool timed_wait (const boost::posix_time::ptime &abs_time)
 Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true. More...
 

Detailed Description

Wraps a interprocess_semaphore that can be placed in shared memory and can be shared between processes.

Allows timed lock tries

Constructor & Destructor Documentation

boost::interprocess::interprocess_semaphore::interprocess_semaphore ( unsigned int  initialCount)
inline

Creates a interprocess_semaphore with the given initial count.

interprocess_exception if there is an error.

boost::interprocess::interprocess_semaphore::~interprocess_semaphore ( )
inline

Destroys the interprocess_semaphore.

Does not throw

Member Function Documentation

void boost::interprocess::interprocess_semaphore::post ( )
inline

Increments the interprocess_semaphore count.

If there are processes/threads blocked waiting for the interprocess_semaphore, then one of these processes will return successfully from its wait function. If there is an error an interprocess_exception exception is thrown.

References boost::interprocess::ipcdetail::spin_semaphore::post().

Referenced by boost::interprocess::ipcdetail::shm_named_semaphore::post().

bool boost::interprocess::interprocess_semaphore::timed_wait ( const boost::posix_time::ptime abs_time)
inline

Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true.

Otherwise, waits for the interprocess_semaphore to the posted or the timeout expires. If the timeout expires, the function returns false. If the interprocess_semaphore is posted the function returns true. If there is an error throws sem_exception

References boost::interprocess::ipcdetail::spin_semaphore::timed_wait().

Referenced by boost::interprocess::ipcdetail::shm_named_semaphore::timed_wait().

bool boost::interprocess::interprocess_semaphore::try_wait ( )
inline

Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true.

If the value is not greater than zero returns false. If there is an error an interprocess_exception exception is thrown.

References boost::interprocess::ipcdetail::spin_semaphore::try_wait().

Referenced by boost::interprocess::ipcdetail::shm_named_semaphore::try_wait().

void boost::interprocess::interprocess_semaphore::wait ( )
inline

Decrements the interprocess_semaphore.

If the interprocess_semaphore value is not greater than zero, then the calling process/thread blocks until it can decrement the counter. If there is an error an interprocess_exception exception is thrown.

References boost::interprocess::ipcdetail::spin_semaphore::timed_wait(), boost::interprocess::timeout_when_waiting_error, and boost::interprocess::ipcdetail::spin_semaphore::wait().

Referenced by boost::interprocess::ipcdetail::shm_named_semaphore::wait().


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