#include <Lock_Adapter_T.h>
Inheritance diagram for ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >:
Public Types | |
typedef ACE_LOCKING_MECHANISM | ACE_LOCK |
Public Member Functions | |
ACE_Lock_Adapter (ACE_LOCKING_MECHANISM &lock) | |
Constructor. All locking requests will be forwarded to <lock>. | |
ACE_Lock_Adapter (void) | |
virtual | ~ACE_Lock_Adapter (void) |
virtual int | acquire (void) |
Block the thread until the lock is acquired. | |
virtual int | tryacquire (void) |
Conditionally acquire the lock (i.e., won't block). | |
virtual int | release (void) |
Release the lock. | |
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) |
virtual int | remove (void) |
Explicitly destroy the lock. | |
Private Attributes | |
ACE_LOCKING_MECHANISM * | lock_ |
The concrete locking mechanism that all the methods delegate to. | |
bool | delete_lock_ |
This class uses a form of the Adapter pattern.
Definition at line 39 of file Lock_Adapter_T.h.
typedef ACE_LOCKING_MECHANISM ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::ACE_LOCK |
Definition at line 42 of file Lock_Adapter_T.h.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::ACE_Lock_Adapter | ( | ACE_LOCKING_MECHANISM & | lock | ) |
Constructor. All locking requests will be forwarded to <lock>.
Definition at line 9 of file Lock_Adapter_T.inl.
00011 : lock_ (&lock), 00012 delete_lock_ (false) 00013 { 00014 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::ACE_Lock_Adapter | ( | void | ) |
Constructor. Since no lock is provided by the user, one will be created internally.
Definition at line 22 of file Lock_Adapter_T.cpp.
References ACE_NEW.
00023 : lock_ (0), 00024 delete_lock_ (true) 00025 { 00026 ACE_NEW (this->lock_, 00027 ACE_LOCKING_MECHANISM); 00028 }
ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::~ACE_Lock_Adapter | ( | void | ) | [virtual] |
Destructor. If <lock_> was not passed in by the user, it will be deleted.
Definition at line 31 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00032 { 00033 if (this->delete_lock_) 00034 delete this->lock_; 00035 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::acquire | ( | void | ) | [virtual] |
Block the thread until the lock is acquired.
Implements ACE_Lock.
Definition at line 46 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00047 { 00048 return this->lock_->acquire (); 00049 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::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>.
Implements ACE_Lock.
Definition at line 72 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00073 { 00074 return this->lock_->acquire_read (); 00075 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::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>.
Implements ACE_Lock.
Definition at line 82 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00083 { 00084 return this->lock_->acquire_write (); 00085 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::release | ( | void | ) | [virtual] |
Release the lock.
Implements ACE_Lock.
Definition at line 62 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00063 { 00064 return this->lock_->release (); 00065 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::remove | ( | void | ) | [virtual] |
Explicitly destroy the lock.
Implements ACE_Lock.
Definition at line 39 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00040 { 00041 return this->lock_->remove (); 00042 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::tryacquire | ( | void | ) | [virtual] |
Conditionally acquire the lock (i.e., won't block).
Implements ACE_Lock.
Definition at line 54 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00055 { 00056 return this->lock_->tryacquire (); 00057 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::tryacquire_read | ( | void | ) | [virtual] |
Conditionally acquire a read lock. If the locking mechanism doesn't support read locks then this just calls <acquire>.
Implements ACE_Lock.
Definition at line 91 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00092 { 00093 return this->lock_->tryacquire_read (); 00094 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::tryacquire_write | ( | void | ) | [virtual] |
Conditionally acquire a write lock. If the locking mechanism doesn't support read locks then this just calls <acquire>.
Implements ACE_Lock.
Definition at line 100 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00101 { 00102 return this->lock_->tryacquire_write (); 00103 }
int ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::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 110 of file Lock_Adapter_T.cpp.
References ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_.
00111 { 00112 return this->lock_->tryacquire_write_upgrade (); 00113 }
bool ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::delete_lock_ [private] |
This flag keep track of whether we are responsible for deleting the lock
Definition at line 105 of file Lock_Adapter_T.h.
ACE_LOCKING_MECHANISM* ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::lock_ [private] |
The concrete locking mechanism that all the methods delegate to.
Definition at line 101 of file Lock_Adapter_T.h.
Referenced by ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::acquire(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::acquire_read(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::acquire_write(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::release(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::remove(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::tryacquire(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::tryacquire_read(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::tryacquire_write(), ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::tryacquire_write_upgrade(), and ACE_Lock_Adapter< ACE_LOCKING_MECHANISM >::~ACE_Lock_Adapter().