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

A mutex with a global name, so it can be found from different processes. More...

#include <named_mutex.hpp>

Collaboration diagram for boost::interprocess::named_mutex:

Public Types

typedef ipcdetail::shm_named_mutex internal_mutex_type
 

Public Member Functions

 named_mutex (create_only_t create_only, const char *name, const permissions &perm=permissions())
 Creates a global mutex with a name. More...
 
 named_mutex (open_or_create_t open_or_create, const char *name, const permissions &perm=permissions())
 Opens or creates a global mutex with a name. More...
 
 named_mutex (open_only_t open_only, const char *name)
 Opens a global mutex with a name if that mutex is previously created. More...
 
 ~named_mutex ()
 Destroys *this and indicates that the calling process is finished using the resource. More...
 
void unlock ()
 Unlocks a previously locked mutex. More...
 
void lock ()
 Locks the mutex, sleeps when the mutex is already locked. More...
 
bool try_lock ()
 Tries to lock the mutex, returns false when the mutex is already locked, returns true when success. More...
 
bool timed_lock (const boost::posix_time::ptime &abs_time)
 Tries to lock the the mutex until time abs_time, Returns false when timeout expires, returns true when locks. More...
 
internal_mutex_typeinternal_mutex ()
 

Static Public Member Functions

static bool remove (const char *name)
 Erases a named mutex from the system. More...
 

Public Attributes

internal_mutex_type m_mut
 

Friends

class named_condition
 
class ipcdetail::interprocess_tester
 

Detailed Description

A mutex with a global name, so it can be found from different processes.

This mutex can't be placed in shared memory, and each process should have it's own named_mutex.

Member Typedef Documentation

Constructor & Destructor Documentation

boost::interprocess::named_mutex::named_mutex ( create_only_t  create_only,
const char *  name,
const permissions perm = permissions() 
)
inline

Creates a global mutex with a name.

Throws interprocess_exception on error.

boost::interprocess::named_mutex::named_mutex ( open_or_create_t  open_or_create,
const char *  name,
const permissions perm = permissions() 
)
inline

Opens or creates a global mutex with a name.

If the mutex is created, this call is equivalent to named_mutex(create_only_t, ... ) If the mutex is already created, this call is equivalent named_mutex(open_only_t, ... ) Does not throw

boost::interprocess::named_mutex::named_mutex ( open_only_t  open_only,
const char *  name 
)
inline

Opens a global mutex with a name if that mutex is previously created.

If it is not previously created this function throws interprocess_exception.

boost::interprocess::named_mutex::~named_mutex ( )
inline

Destroys *this and indicates that the calling process is finished using the resource.

The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().

Member Function Documentation

internal_mutex_type& boost::interprocess::named_mutex::internal_mutex ( )
inline

References m_mut.

void boost::interprocess::named_mutex::lock ( )
inline

Locks the mutex, sleeps when the mutex is already locked.

Throws interprocess_exception if a severe error is found

References boost::interprocess::ipcdetail::shm_named_mutex::lock(), and m_mut.

bool boost::interprocess::named_mutex::remove ( const char *  name)
inlinestatic

Erases a named mutex from the system.

Returns false on error. Never throws.

References boost::interprocess::ipcdetail::shm_named_mutex::remove().

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

Tries to lock the the mutex until time abs_time, Returns false when timeout expires, returns true when locks.

Throws interprocess_exception if a severe error is found

References m_mut, and boost::interprocess::ipcdetail::shm_named_mutex::timed_lock().

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

Tries to lock the mutex, returns false when the mutex is already locked, returns true when success.

Throws interprocess_exception if a severe error is found

References m_mut, and boost::interprocess::ipcdetail::shm_named_mutex::try_lock().

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

Unlocks a previously locked mutex.

References m_mut, and boost::interprocess::ipcdetail::shm_named_mutex::unlock().

Friends And Related Function Documentation

friend class ipcdetail::interprocess_tester
friend
friend class named_condition
friend

Member Data Documentation

internal_mutex_type boost::interprocess::named_mutex::m_mut

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