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_mutex Class Reference

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

#include <interprocess_mutex.hpp>

Public Types

typedef ipcdetail::spin_mutex internal_mutex_type
 

Public Member Functions

 interprocess_mutex ()
 Constructor. More...
 
 ~interprocess_mutex ()
 Destructor. More...
 
void lock ()
 Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex, it waits until it can obtain the ownership. More...
 
bool try_lock ()
 Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex returns immediately. More...
 
bool timed_lock (const boost::posix_time::ptime &abs_time)
 Effects: The calling thread will try to obtain exclusive ownership of the mutex if it can do so in until the specified time is reached. More...
 
void unlock ()
 Effects: The calling thread releases the exclusive ownership of the mutex. More...
 
internal_mutex_typeinternal_mutex ()
 
const internal_mutex_typeinternal_mutex () const
 

Friends

class interprocess_condition
 
class ipcdetail::robust_emulation_helpers::mutex_traits< interprocess_mutex >
 

Detailed Description

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

Allows timed lock tries

Member Typedef Documentation

Constructor & Destructor Documentation

boost::interprocess::interprocess_mutex::interprocess_mutex ( )
inline

Constructor.

Throws interprocess_exception on error.

boost::interprocess::interprocess_mutex::~interprocess_mutex ( )
inline

Destructor.

If any process uses the mutex after the destructor is called the result is undefined. Does not throw.

Member Function Documentation

internal_mutex_type& boost::interprocess::interprocess_mutex::internal_mutex ( )
inline
const internal_mutex_type& boost::interprocess::interprocess_mutex::internal_mutex ( ) const
inline
void boost::interprocess::interprocess_mutex::lock ( )
inline

Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex, it waits until it can obtain the ownership.

If a thread takes ownership of the mutex the mutex must be unlocked by the same mutex. Throws: interprocess_exception on error.

References boost::interprocess::ipcdetail::spin_mutex::lock(), boost::interprocess::ipcdetail::spin_mutex::timed_lock(), and boost::interprocess::timeout_when_locking_error.

Referenced by boost::interprocess::ipcdetail::shm_named_mutex::lock().

bool boost::interprocess::interprocess_mutex::timed_lock ( const boost::posix_time::ptime abs_time)
inline

Effects: The calling thread will try to obtain exclusive ownership of the mutex if it can do so in until the specified time is reached.

If the mutex supports recursive locking, the mutex must be unlocked the same number of times it is locked. Returns: If the thread acquires ownership of the mutex, returns true, if the timeout expires returns false. Throws: interprocess_exception on error.

References boost::interprocess::ipcdetail::spin_mutex::timed_lock().

Referenced by boost::interprocess::ipcdetail::shm_named_mutex::timed_lock().

bool boost::interprocess::interprocess_mutex::try_lock ( )
inline

Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex returns immediately.

Returns: If the thread acquires ownership of the mutex, returns true, if the another thread has ownership of the mutex, returns false. Throws: interprocess_exception on error.

References boost::interprocess::ipcdetail::spin_mutex::try_lock().

Referenced by boost::interprocess::ipcdetail::shm_named_mutex::try_lock().

void boost::interprocess::interprocess_mutex::unlock ( )
inline

Effects: The calling thread releases the exclusive ownership of the mutex.

Throws: interprocess_exception on error.

References boost::interprocess::ipcdetail::spin_mutex::unlock().

Referenced by boost::interprocess::ipcdetail::shm_named_mutex::unlock().

Friends And Related Function Documentation

friend class interprocess_condition
friend

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