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

ACE_Adaptive_Lock Class Reference

An adaptive general locking class that defers the decision of lock type to run time. More...

#include <Synch.h>

Inheritance diagram for ACE_Adaptive_Lock:

Inheritance graph
[legend]
Collaboration diagram for ACE_Adaptive_Lock:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual ~ACE_Adaptive_Lock (void)
 You must also override the destructor function to match with how you construct the underneath <lock_>. More...

virtual int remove (void)
virtual int acquire (void)
 Block the thread until the lock is acquired. Returns -1 on failure. More...

virtual int tryacquire (void)
virtual int release (void)
 Release the lock. Returns -1 on failure. More...

virtual int acquire_read (void)
virtual int acquire_write (void)
virtual int tryacquire_read (void)
virtual int tryacquire_write (void)
virtual int tryacquire_write_upgrade (void)
void dump (void) const

Protected Methods

 ACE_Adaptive_Lock (void)

Protected Attributes

ACE_Locklock_

Detailed Description

An adaptive general locking class that defers the decision of lock type to run time.

This class, as ACE_Lock, provide a set of general locking APIs. However, it defers our decision of what kind of lock to use to the run time and delegates all locking operations to the actual lock. Users must define a constructor in their subclass to initialize <lock_>.

Definition at line 124 of file Synch.h.


Constructor & Destructor Documentation

ACE_Adaptive_Lock::~ACE_Adaptive_Lock void    [virtual]
 

You must also override the destructor function to match with how you construct the underneath <lock_>.

Definition at line 37 of file Synch.cpp.

00038 {
00039 }

ACE_Adaptive_Lock::ACE_Adaptive_Lock void    [protected]
 

Create and initialize create the actual lcok used in the class. The default constructor simply set the <lock_> to 0 (null). You must overwrite this method for this class to work.

Definition at line 32 of file Synch.cpp.

00033   : lock_ (0)
00034 {
00035 }


Member Function Documentation

int ACE_Adaptive_Lock::acquire void    [virtual]
 

Block the thread until the lock is acquired. Returns -1 on failure.

Implements ACE_Lock.

Definition at line 48 of file Synch.cpp.

References ACE_Lock::acquire, and lock_.

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

int ACE_Adaptive_Lock::acquire_read void    [virtual]
 

Block until the thread acquires a read lock. If the locking mechanism doesn't support read locks then this just calls <acquire>. Returns -1 on failure.

Implements ACE_Lock.

Definition at line 66 of file Synch.cpp.

References ACE_Lock::acquire_read, and lock_.

00067 {
00068   return this->lock_->acquire_read ();
00069 }

int ACE_Adaptive_Lock::acquire_write void    [virtual]
 

Block until the thread acquires a write lock. If the locking mechanism doesn't support read locks then this just calls <acquire>. Returns -1 on failure.

Implements ACE_Lock.

Definition at line 72 of file Synch.cpp.

References ACE_Lock::acquire_write, and lock_.

00073 {
00074   return this->lock_->acquire_write ();
00075 }

void ACE_Adaptive_Lock::dump void    const
 

Definition at line 96 of file Synch.cpp.

00097 {
00098   //  return this->lock_->dump ();
00099 }

int ACE_Adaptive_Lock::release void    [virtual]
 

Release the lock. Returns -1 on failure.

Implements ACE_Lock.

Definition at line 60 of file Synch.cpp.

References lock_, and ACE_Lock::release.

00061 {
00062   return this->lock_->release ();
00063 }

int ACE_Adaptive_Lock::remove void    [virtual]
 

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

Implements ACE_Lock.

Definition at line 42 of file Synch.cpp.

References lock_, and ACE_Lock::remove.

00043 {
00044   return this->lock_->remove ();
00045 }

int ACE_Adaptive_Lock::tryacquire void    [virtual]
 

Conditionally acquire the 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>.

Implements ACE_Lock.

Definition at line 54 of file Synch.cpp.

References lock_, and ACE_Lock::tryacquire.

00055 {
00056   return this->lock_->tryacquire ();
00057 }

int ACE_Adaptive_Lock::tryacquire_read void    [virtual]
 

Conditionally acquire a read lock. If the locking mechanism doesn't support read locks then this just calls <acquire>. Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>.

Implements ACE_Lock.

Definition at line 78 of file Synch.cpp.

References lock_, and ACE_Lock::tryacquire_read.

00079 {
00080   return this->lock_->tryacquire_read ();
00081 }

int ACE_Adaptive_Lock::tryacquire_write void    [virtual]
 

Conditionally acquire a write lock. If the locking mechanism doesn't support read locks then this just calls <acquire>. Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>.

Implements ACE_Lock.

Definition at line 84 of file Synch.cpp.

References lock_, and ACE_Lock::tryacquire_write.

00085 {
00086   return this->lock_->tryacquire_write ();
00087 }

int ACE_Adaptive_Lock::tryacquire_write_upgrade void    [virtual]
 

Conditionally try to upgrade a lock held for read to a write lock. If the locking mechanism doesn't support read locks then this just calls <acquire>. Returns 0 on success, -1 on failure.

Implements ACE_Lock.

Definition at line 90 of file Synch.cpp.

References lock_, and ACE_Lock::tryacquire_write_upgrade.

00091 {
00092   return this->lock_->tryacquire_write_upgrade ();
00093 }


Member Data Documentation

ACE_Lock* ACE_Adaptive_Lock::lock_ [protected]
 

Definition at line 152 of file Synch.h.

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


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