ACE_Adaptive_Lock Class Reference

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

#include <Lock.h>

Inheritance diagram for ACE_Adaptive_Lock:

Inheritance graph
[legend]
Collaboration diagram for ACE_Adaptive_Lock:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~ACE_Adaptive_Lock (void)
virtual int remove (void)
virtual int acquire (void)
virtual int tryacquire (void)
virtual int release (void)
 Release the lock. Returns -1 on failure.

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 Member Functions

 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 .

Definition at line 123 of file Lock.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 .

Definition at line 22 of file Lock.cpp.

00023 {
00024 }

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 to 0 (null). You must overwrite this method for this class to work.

Definition at line 17 of file Lock.cpp.

00018   : lock_ (0)
00019 {
00020 }


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 33 of file Lock.cpp.

References ACE_Lock::acquire().

00034 {
00035   return this->lock_->acquire ();
00036 }

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 . Returns -1 on failure.

Implements ACE_Lock.

Definition at line 51 of file Lock.cpp.

References ACE_Lock::acquire_read().

00052 {
00053   return this->lock_->acquire_read ();
00054 }

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 . Returns -1 on failure.

Implements ACE_Lock.

Definition at line 57 of file Lock.cpp.

References ACE_Lock::acquire_write().

00058 {
00059   return this->lock_->acquire_write ();
00060 }

void ACE_Adaptive_Lock::dump void   )  const
 

Definition at line 81 of file Lock.cpp.

00082 {
00083 #if defined (ACE_HAS_DUMP)
00084   //  return this->lock_->dump ();
00085 #endif /* ACE_HAS_DUMP */
00086 }

int ACE_Adaptive_Lock::release void   )  [virtual]
 

Release the lock. Returns -1 on failure.

Implements ACE_Lock.

Definition at line 45 of file Lock.cpp.

References ACE_Lock::release().

00046 {
00047   return this->lock_->release ();
00048 }

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 27 of file Lock.cpp.

References ACE_Lock::remove().

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

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, is set to .

Implements ACE_Lock.

Definition at line 39 of file Lock.cpp.

References ACE_Lock::tryacquire().

00040 {
00041   return this->lock_->tryacquire ();
00042 }

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 . Returns -1 on failure. If we "failed" because someone else already had the lock, is set to .

Implements ACE_Lock.

Definition at line 63 of file Lock.cpp.

References ACE_Lock::tryacquire_read().

00064 {
00065   return this->lock_->tryacquire_read ();
00066 }

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 . Returns -1 on failure. If we "failed" because someone else already had the lock, is set to .

Implements ACE_Lock.

Definition at line 69 of file Lock.cpp.

References ACE_Lock::tryacquire_write().

00070 {
00071   return this->lock_->tryacquire_write ();
00072 }

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 . Returns 0 on success, -1 on failure.

Implements ACE_Lock.

Definition at line 75 of file Lock.cpp.

References ACE_Lock::tryacquire_write_upgrade().

00076 {
00077   return this->lock_->tryacquire_write_upgrade ();
00078 }


Member Data Documentation

ACE_Lock* ACE_Adaptive_Lock::lock_ [protected]
 

Definition at line 151 of file Lock.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:19:08 2006 for ACE by doxygen 1.3.6