NAME
ACE_Lock_Adapter - This is an adapter that allows applications to transparently combine the ACE_Lock abstract base class (which contains pure virtual methods) with any of the other concrete ACE synchronization classes (e.g., ACE_Mutex, ACE_Semaphore, ACE_RW_Mutex, etc.).
SYNOPSIS
#include <ace/Synch_T.h>
template<class ACE_LOCKING_MECHANISM>
class ACE_Lock_Adapter : public ACE_Lock
{
public:
typedef ACE_LOCKING_MECHANISM ACE_LOCK;
ACE_Lock_Adapter (ACE_LOCKING_MECHANISM &lock);
ACE_Lock_Adapter (void);
virtual ~ACE_Lock_Adapter (void);
virtual int acquire (void);
virtual int tryacquire (void);
virtual int release (void);
virtual int acquire_read (void);
virtual int acquire_write (void);
virtual int tryacquire_read (void);
virtual int tryacquire_write (void);
virtual int remove (void);
private:
ACE_LOCKING_MECHANISM *lock_;
int delete_lock_;
};
DESCRIPTION
This class uses a form of the Adapter pattern.
Initialization/Finalization methods.
ACE_Lock_Adapter (ACE_LOCKING_MECHANISM &lock);
Constructor. All locking requests will be forwarded to lock.
ACE_Lock_Adapter (void);
Constructor. Since no lock is provided by the user, one will be created internally.
virtual ~ACE_Lock_Adapter (void);
Destructor. If lock_ was not passed in by the user, it will be deleted.
Lock accessors.
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);
Block until the thread acquires a read lock. If the locking mechanism doesn't support read locks then this just calls acquire.
virtual int acquire_write (void);
Block until the thread acquires a write lock. If the locking mechanism doesn't support read locks then this just calls acquire.
virtual int tryacquire_read (void);
Conditionally acquire a read lock. If the locking mechanism doesn't support read locks then this just calls acquire.
virtual int tryacquire_write (void);
Conditionally acquire a write lock. If the locking mechanism doesn't support read locks then this just calls acquire.
virtual int remove (void);
Explicitly destroy the lock.
AUTHOR
Doug Schmidt
LIBRARY
ace