Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_RW_Process_Mutex Class Reference

Wrapper for readers/writer locks that exist across processes. More...

#include <RW_Process_Mutex.h>

Collaboration diagram for ACE_RW_Process_Mutex:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_RW_Process_Mutex (const ACE_TCHAR *name=0, int flags=O_CREAT|O_RDWR)
 Create a readers/writer <Process_Mutex>, passing in the optional <name>. If not specified, a name is generated. More...

 ~ACE_RW_Process_Mutex (void)
int remove (void)
int acquire (void)
 Acquire lock ownership (wait on queue if necessary). More...

int tryacquire (void)
int release (void)
 Release lock and unblock a thread at head of queue. More...

int acquire_read (void)
 Acquire lock ownership (wait on queue if necessary). More...

int acquire_write (void)
 Acquire lock ownership (wait on queue if necessary). More...

int tryacquire_read (void)
int tryacquire_write (void)
int tryacquire_write_upgrade (void)
 Attempt to upgrade a read lock to a write lock. Returns 0 on success, -1 on failure. More...

const ACE_File_Locklock (void) const
 Return the underlying lock. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Methods

const ACE_TCHARunique_name (void)
 Create and return the unique name. More...


Private Attributes

ACE_TCHAR name_ [ACE_UNIQUE_NAME_LEN]
 If the user does not provide a name we generate a unique name in this buffer. More...

ACE_File_Lock lock_
 We need this to get the readers/writer semantics... More...


Detailed Description

Wrapper for readers/writer locks that exist across processes.

Note that because this class uses the <ACE_File_Lock> as its implementation it only can be reliably used between separate processes, rather than threads in the same process. This isn't a limitation of ACE, it's simply the file lock semantics on UNIX and Win32.

Definition at line 34 of file RW_Process_Mutex.h.


Constructor & Destructor Documentation

ACE_RW_Process_Mutex::ACE_RW_Process_Mutex const ACE_TCHAR   name = 0,
int    flags = O_CREAT|O_RDWR
 

Create a readers/writer <Process_Mutex>, passing in the optional <name>. If not specified, a name is generated.

Definition at line 23 of file RW_Process_Mutex.cpp.

References ACE_DEFAULT_OPEN_PERMS, and ACE_TCHAR.

00025   : lock_ (name ? name : this->unique_name (), flags
00026 #if defined (ACE_WIN32)
00027            , ACE_DEFAULT_OPEN_PERMS)
00028 #else
00029            , S_IRUSR | S_IWUSR)
00030 #endif /* ACE_WIN32 */
00031 {
00032 // ACE_TRACE ("ACE_RW_Process_Mutex::ACE_RW_Process_Mutex");
00033 }

ACE_RW_Process_Mutex::~ACE_RW_Process_Mutex void   
 

Definition at line 35 of file RW_Process_Mutex.cpp.

00036 {
00037 // ACE_TRACE ("ACE_RW_Process_Mutex::~ACE_RW_Process_Mutex");
00038 }


Member Function Documentation

ACE_INLINE int ACE_RW_Process_Mutex::acquire void   
 

Acquire lock ownership (wait on queue if necessary).

Definition at line 13 of file RW_Process_Mutex.inl.

References ACE_File_Lock::acquire, and lock_.

00014 {
00015   return this->lock_.acquire ();
00016 }

ACE_INLINE int ACE_RW_Process_Mutex::acquire_read void   
 

Acquire lock ownership (wait on queue if necessary).

Definition at line 34 of file RW_Process_Mutex.inl.

References ACE_File_Lock::acquire_read, and lock_.

00035 {
00036   return this->lock_.acquire_read ();
00037 }

ACE_INLINE int ACE_RW_Process_Mutex::acquire_write void   
 

Acquire lock ownership (wait on queue if necessary).

Definition at line 41 of file RW_Process_Mutex.inl.

References ACE_File_Lock::acquire_write, and lock_.

00042 {
00043   return this->lock_.acquire_write ();
00044 }

void ACE_RW_Process_Mutex::dump void    const
 

Dump the state of an object.

Definition at line 41 of file RW_Process_Mutex.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_File_Lock::dump, LM_DEBUG, and lock_.

00042 {
00043 // ACE_TRACE ("ACE_RW_Process_Mutex::dump");
00044   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00045   this->lock_.dump ();
00046   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00047 }

ACE_INLINE const ACE_File_Lock & ACE_RW_Process_Mutex::lock void    const
 

Return the underlying lock.

Definition at line 68 of file RW_Process_Mutex.inl.

References lock_.

00069 {
00070 // ACE_TRACE ("ACE_RW_Process_Mutex::lock");
00071   return this->lock_;
00072 }

ACE_INLINE int ACE_RW_Process_Mutex::release void   
 

Release lock and unblock a thread at head of queue.

Definition at line 27 of file RW_Process_Mutex.inl.

References lock_, and ACE_File_Lock::release.

00028 {
00029   return this->lock_.release ();
00030 }

ACE_INLINE int ACE_RW_Process_Mutex::remove void   
 

Explicitly destroy the mutex. Note that only one thread should call this method since it doesn't protect against race conditions.

Definition at line 6 of file RW_Process_Mutex.inl.

References lock_, and ACE_File_Lock::remove.

00007 {
00008   return this->lock_.remove ();
00009 }

ACE_INLINE int ACE_RW_Process_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>.

Definition at line 20 of file RW_Process_Mutex.inl.

References lock_, and ACE_File_Lock::tryacquire.

00021 {
00022   return this->lock_.tryacquire ();
00023 }

ACE_INLINE int ACE_RW_Process_Mutex::tryacquire_read void   
 

Conditionally acquire a lock (i.e., won't block). Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>.

Definition at line 48 of file RW_Process_Mutex.inl.

References lock_, and ACE_File_Lock::tryacquire_read.

00049 {
00050   return this->lock_.tryacquire_read ();
00051 }

ACE_INLINE int ACE_RW_Process_Mutex::tryacquire_write void   
 

Conditionally acquire a lock (i.e., won't block). Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>.

Definition at line 55 of file RW_Process_Mutex.inl.

References lock_, and ACE_File_Lock::tryacquire_write.

00056 {
00057   return this->lock_.tryacquire_write ();
00058 }

ACE_INLINE int ACE_RW_Process_Mutex::tryacquire_write_upgrade void   
 

Attempt to upgrade a read lock to a write lock. Returns 0 on success, -1 on failure.

Definition at line 62 of file RW_Process_Mutex.inl.

References lock_, and ACE_File_Lock::tryacquire_write_upgrade.

00063 {
00064   return this->lock_.tryacquire_write_upgrade ();
00065 }

const ACE_TCHAR * ACE_RW_Process_Mutex::unique_name void    [private]
 

Create and return the unique name.

Definition at line 17 of file RW_Process_Mutex.cpp.

References ACE_UNIQUE_NAME_LEN, name_, and ACE::unique_name.

00018 {
00019   ACE::unique_name (this, this->name_, ACE_UNIQUE_NAME_LEN);
00020   return this->name_;
00021 }


Member Data Documentation

ACE_RW_Process_Mutex::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 95 of file RW_Process_Mutex.h.

ACE_File_Lock ACE_RW_Process_Mutex::lock_ [private]
 

We need this to get the readers/writer semantics...

Definition at line 106 of file RW_Process_Mutex.h.

Referenced by acquire, acquire_read, acquire_write, dump, lock, release, remove, tryacquire, tryacquire_read, tryacquire_write, and tryacquire_write_upgrade.

ACE_TCHAR ACE_RW_Process_Mutex::name_[ACE_UNIQUE_NAME_LEN] [private]
 

If the user does not provide a name we generate a unique name in this buffer.

Definition at line 100 of file RW_Process_Mutex.h.

Referenced by unique_name.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:55:27 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002