ACE 8.0.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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]

Public Member Functions

virtual ~ACE_Adaptive_Lock ()=default
 
virtual int remove ()
 
virtual int acquire ()
 
virtual int tryacquire ()
 
virtual int release ()
 Release the lock. Returns -1 on failure.
 
virtual int acquire_read ()
 
virtual int acquire_write ()
 
virtual int tryacquire_read ()
 
virtual int tryacquire_write ()
 
virtual int tryacquire_write_upgrade ()
 
void dump () const
 
- Public Member Functions inherited from ACE_Lock
 ACE_Lock ()
 CE needs a default constructor here.
 
virtual ~ACE_Lock ()=default
 Noop virtual destructor.
 

Protected Member Functions

 ACE_Adaptive_Lock ()=default
 

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_.

Constructor & Destructor Documentation

◆ ~ACE_Adaptive_Lock()

virtual ACE_Adaptive_Lock::~ACE_Adaptive_Lock ( )
virtualdefault

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

◆ ACE_Adaptive_Lock()

ACE_Adaptive_Lock::ACE_Adaptive_Lock ( )
protecteddefault

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

Member Function Documentation

◆ acquire()

int ACE_Adaptive_Lock::acquire ( )
virtual

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

Implements ACE_Lock.

◆ acquire_read()

int ACE_Adaptive_Lock::acquire_read ( )
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.

◆ acquire_write()

int ACE_Adaptive_Lock::acquire_write ( )
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.

◆ dump()

void ACE_Adaptive_Lock::dump ( ) const

◆ release()

int ACE_Adaptive_Lock::release ( )
virtual

Release the lock. Returns -1 on failure.

Implements ACE_Lock.

◆ remove()

int ACE_Adaptive_Lock::remove ( )
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.

◆ tryacquire()

int ACE_Adaptive_Lock::tryacquire ( )
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.

◆ tryacquire_read()

int ACE_Adaptive_Lock::tryacquire_read ( )
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.

◆ tryacquire_write()

int ACE_Adaptive_Lock::tryacquire_write ( )
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.

◆ tryacquire_write_upgrade()

int ACE_Adaptive_Lock::tryacquire_write_upgrade ( )
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.

Member Data Documentation

◆ lock_

ACE_Lock* ACE_Adaptive_Lock::lock_ {}
protected

The documentation for this class was generated from the following files: