ACE_Mutex Class Reference

ACE_Mutex wrapper (valid in same process or across processes (depending on TYPE flag)). More...

#include <Mutex.h>

List of all members.

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 (void)
 Implicitly destroy the mutex.
int remove (void)
 Explicitly destroy the mutex.
int acquire (void)
 Acquire lock ownership (wait on queue if necessary).
int acquire (ACE_Time_Value &tv)
int acquire (ACE_Time_Value *tv)
int tryacquire (void)
 Conditionally acquire lock (i.e., don't wait on queue).
int release (void)
 Release lock and unblock a thread at head of queue.
int acquire_read (void)
 Acquire mutex ownership.
int acquire_write (void)
 Acquire mutex ownership.
int tryacquire_read (void)
 Conditionally acquire mutex (i.e., won't block).
int tryacquire_write (void)
 Conditionally acquire mutex (i.e., won't block).
int tryacquire_write_upgrade (void)
const ACE_mutex_t & lock (void) const
 Return the underlying mutex.
void dump (void) const
 Dump the state of an object.

Public Attributes

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

Private Member Functions

void operator= (const ACE_Mutex &)
 ACE_Mutex (const ACE_Mutex &)


Detailed Description

ACE_Mutex wrapper (valid in same process or across processes (depending on TYPE flag)).


Constructor & Destructor Documentation

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 ( void   ) 

Implicitly destroy the mutex.

ACE_Mutex::ACE_Mutex ( const ACE_Mutex  )  [private]


Member Function Documentation

ACE_INLINE int ACE_Mutex::acquire ( ACE_Time_Value tv  ) 

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.

ACE_INLINE int ACE_Mutex::acquire ( ACE_Time_Value tv  ) 

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.

ACE_INLINE int ACE_Mutex::acquire ( void   ) 

Acquire lock ownership (wait on queue if necessary).

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_Mutex::acquire_read ( void   ) 

Acquire mutex ownership.

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

ACE_INLINE int ACE_Mutex::acquire_write ( void   ) 

Acquire mutex ownership.

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

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_Mutex::dump ( void   )  const

Dump the state of an object.

ACE_INLINE const ACE_mutex_t & ACE_Mutex::lock ( void   )  const

Return the underlying mutex.

void ACE_Mutex::operator= ( const ACE_Mutex  )  [private]

ACE_INLINE int ACE_Mutex::release ( void   ) 

Release lock and unblock a thread at head of queue.

ACE_INLINE int ACE_Mutex::remove ( void   ) 

Explicitly destroy the mutex.

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

ACE_INLINE int ACE_Mutex::tryacquire ( void   ) 

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.

ACE_INLINE int ACE_Mutex::tryacquire_read ( void   ) 

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.

ACE_INLINE int ACE_Mutex::tryacquire_write ( void   ) 

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.

ACE_INLINE int ACE_Mutex::tryacquire_write_upgrade ( void   ) 

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.


Member Data Documentation

ACE_Mutex::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

ACE_mutex_t ACE_Mutex::lock_

Mutex type supported by the OS.

int 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:
Generated on Sun Jul 9 09:23:56 2006 for ACE by  doxygen 1.4.7-1