ACE 8.0.1
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
ACE_Mutex Class Reference

ACE_Mutex wrapper (valid in same process or across processes (depending on TYPE flag)). In general, however, we recommend using ACE_Process_Mutex or ACE_Thread_Mutex rather than ACE_Mutex. More...

#include <Mutex.h>

Public Member Functions

 ACE_Mutex (int type=USYNC_THREAD, const ACE_TCHAR *name=0, ACE_mutexattr_t *arg=0, mode_t mode=ACE_DEFAULT_FILE_PERMS)
 Initialize the mutex.
 
 ~ACE_Mutex ()
 Implicitly destroy the mutex.
 
int remove ()
 Explicitly destroy the mutex.
 
int acquire ()
 Acquire lock ownership (wait on queue if necessary).
 
int acquire (ACE_Time_Value &tv)
 
int acquire (ACE_Time_Value *tv)
 
int tryacquire ()
 Conditionally acquire lock (i.e., don't wait on queue).
 
int release ()
 Release lock and unblock a thread at head of queue.
 
int acquire_read ()
 Acquire mutex ownership.
 
int acquire_write ()
 Acquire mutex ownership.
 
int tryacquire_read ()
 Conditionally acquire mutex (i.e., won't block).
 
int tryacquire_write ()
 Conditionally acquire mutex (i.e., won't block).
 
int tryacquire_write_upgrade ()
 
const ACE_mutex_tlock () const
 Return the underlying mutex.
 
ACE_mutex_tlock ()
 
void dump () const
 Dump the state of an object.
 

Static Public Member Functions

static int unlink (const ACE_TCHAR *name)
 

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.
 
ACE_mutex_t lock_
 Mutex type supported by the OS.
 
bool removed_
 

Private Member Functions

ACE_Mutexoperator= (const ACE_Mutex &)=delete
 
 ACE_Mutex (const ACE_Mutex &)=delete
 

Detailed Description

ACE_Mutex wrapper (valid in same process or across processes (depending on TYPE flag)). In general, however, we recommend using ACE_Process_Mutex or ACE_Thread_Mutex rather than ACE_Mutex.

Constructor & Destructor Documentation

◆ ACE_Mutex() [1/2]

ACE_Mutex::ACE_Mutex ( int type = USYNC_THREAD,
const ACE_TCHAR * name = 0,
ACE_mutexattr_t * arg = 0,
mode_t mode = ACE_DEFAULT_FILE_PERMS )

Initialize the mutex.

◆ ~ACE_Mutex()

ACE_Mutex::~ACE_Mutex ( )

Implicitly destroy the mutex.

◆ ACE_Mutex() [2/2]

ACE_Mutex::ACE_Mutex ( const ACE_Mutex & )
privatedelete

Member Function Documentation

◆ acquire() [1/3]

int ACE_Mutex::acquire ( )
inline

Acquire lock ownership (wait on queue if necessary).

◆ acquire() [2/3]

int ACE_Mutex::acquire ( ACE_Time_Value & tv)
inline

Block the thread until the mutex is acquired or tv times out, in which case -1 is returned and errno == ETIME.

Note
tv is assumed to be in "absolute" rather than " relative" time. The value of tv is updated upon return to show the actual(absolute) acquisition time.

◆ acquire() [3/3]

int ACE_Mutex::acquire ( ACE_Time_Value * tv)
inline

Block the thread until the mutex is acquired or *tv times out, in which case -1 is returned and errno == ETIME. If tv == 0 then call acquire() directly. Otherwise, block the thread until the mutex is acquired or tv times out, in which case -1 is returned and errno == ETIME.

Note
*tv is assumed to be in "absolute" rather than "relative" time. The value of *tv is updated upon return to show the actual (absolute) acquisition time.

◆ acquire_read()

int ACE_Mutex::acquire_read ( )
inline

Acquire mutex ownership.

This calls acquire and is only here to make the ACE_Mutex interface consistent with the other synchronization APIs.

◆ acquire_write()

int ACE_Mutex::acquire_write ( )
inline

Acquire mutex ownership.

This calls acquire and is only here to make the ACE_Mutex interface consistent with the other synchronization APIs.

◆ dump()

void ACE_Mutex::dump ( ) const

Dump the state of an object.

◆ lock() [1/2]

ACE_mutex_t & ACE_Mutex::lock ( )
inline

◆ lock() [2/2]

const ACE_mutex_t & ACE_Mutex::lock ( ) const
inline

Return the underlying mutex.

◆ operator=()

ACE_Mutex & ACE_Mutex::operator= ( const ACE_Mutex & )
privatedelete

◆ release()

int ACE_Mutex::release ( )
inline

Release lock and unblock a thread at head of queue.

◆ remove()

int ACE_Mutex::remove ( )
inline

Explicitly destroy the mutex.

Note
Only one thread should call this method since it doesn't protect against race conditions.

◆ tryacquire()

int ACE_Mutex::tryacquire ( )
inline

Conditionally acquire lock (i.e., don't wait on queue).

Returns
-1 on failure. If we "failed" because someone else already had the lock, errno is set to EBUSY.

◆ tryacquire_read()

int ACE_Mutex::tryacquire_read ( )
inline

Conditionally acquire mutex (i.e., won't block).

This calls tryacquire and is only here to make the ACE_Mutex interface consistent with the other synchronization APIs.

Returns
-1 on failure. If we "failed" because someone else already had the lock, errno is set to EBUSY.

◆ tryacquire_write()

int ACE_Mutex::tryacquire_write ( )
inline

Conditionally acquire mutex (i.e., won't block).

This calls tryacquire and is only here to make the ACE_Mutex interface consistent with the other synchronization APIs.

Returns
-1 on failure. If we "failed" because someone else already had the lock, errno is set to EBUSY.

◆ tryacquire_write_upgrade()

int ACE_Mutex::tryacquire_write_upgrade ( )
inline

This is only here for consistency with the other synchronization APIs and usability with Lock adapters. Assumes the caller already has acquired the mutex and returns 0 in all cases.

◆ unlink()

int ACE_Mutex::unlink ( const ACE_TCHAR * name)
static

If a file was created as the underlying storage for the mutex, remove it from the filesystem (for process-shared mutexes).

Member Data Documentation

◆ ACE_ALLOC_HOOK_DECLARE

ACE_Mutex::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

◆ lock_

ACE_mutex_t ACE_Mutex::lock_

Mutex type supported by the OS.

◆ removed_

bool ACE_Mutex::removed_

Keeps track of whether remove has been called yet to avoid multiple remove calls, e.g., explicitly and implicitly in the destructor. This flag isn't protected by a lock, so make sure that you don't have multiple threads simultaneously calling remove on the same object, which is a bad idea anyway.


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