ACE 8.0.5
Loading...
Searching...
No Matches
ACE_Reverse_Lock< ACE_LOCKING_MECHANISM > Class Template Reference

A reverse (or anti) lock. More...

#include <Reverse_Lock_T.h>

Inheritance diagram for ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >:
Collaboration diagram for ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >:

Public Types

typedef ACE_LOCKING_MECHANISM ACE_LOCK

Public Member Functions

 ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock, ACE_Acquire_Method::METHOD_TYPE acquire_method=ACE_Acquire_Method::ACE_REGULAR)
 Constructor. All locking requests will be forwarded to lock.
virtual ~ACE_Reverse_Lock ()=default
virtual int acquire ()
 Release the lock.
virtual int tryacquire ()
 Release the lock.
virtual int release ()
 Acquire the lock.
virtual int acquire_read ()
 Release the lock.
virtual int acquire_write ()
 Release the lock.
virtual int tryacquire_read ()
 Release the lock.
virtual int tryacquire_write ()
 Release the lock.
virtual int tryacquire_write_upgrade ()
 Release the lock.
virtual int remove ()
 Explicitly destroy the lock.
Public Member Functions inherited from ACE_Lock
 ACE_Lock ()
 CE needs a default constructor here.
virtual ~ACE_Lock ()=default
 Noop virtual destructor.

Private Attributes

ACE_LOCKING_MECHANISM & lock_
 The concrete locking mechanism that all the methods delegate to.
ACE_Acquire_Method::METHOD_TYPE acquire_method_
 This indicates what kind of acquire method will be called.

Detailed Description

template<class ACE_LOCKING_MECHANISM>
class ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >

A reverse (or anti) lock.

This is an interesting adapter class that changes a lock into a reverse lock, i.e., <acquire> on this class calls <release> on the lock, and <release> on this class calls <acquire> on the lock. One motivation for this class is when we temporarily want to release a lock (which we have already acquired) but then reacquire it soon after. An alternative design would be to add a Anti_Guard or Reverse_Guard class which would <release> on construction and <acquire> destruction. However, there are many varieties of the Guard class and this design choice would lead to at least 6 new classes. One new ACE_Reverse_Lock class seemed more reasonable.

Member Typedef Documentation

◆ ACE_LOCK

template<class ACE_LOCKING_MECHANISM>
typedef ACE_LOCKING_MECHANISM ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::ACE_LOCK

Constructor & Destructor Documentation

◆ ACE_Reverse_Lock()

template<class ACE_LOCKING_MECHANISM>
ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::ACE_Reverse_Lock ( ACE_LOCKING_MECHANISM & lock,
ACE_Acquire_Method::METHOD_TYPE acquire_method = ACE_Acquire_Method::ACE_REGULAR )
inline

Constructor. All locking requests will be forwarded to lock.

◆ ~ACE_Reverse_Lock()

template<class ACE_LOCKING_MECHANISM>
virtual ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::~ACE_Reverse_Lock ( )
virtualdefault

Destructor. If <lock_> was not passed in by the user, it will be deleted.

Member Function Documentation

◆ acquire()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::acquire ( )
virtual

Release the lock.

Implements ACE_Lock.

◆ acquire_read()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::acquire_read ( )
virtual

Release the lock.

Implements ACE_Lock.

◆ acquire_write()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::acquire_write ( )
virtual

Release the lock.

Implements ACE_Lock.

◆ release()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::release ( )
virtual

Acquire the lock.

Implements ACE_Lock.

◆ remove()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::remove ( )
virtual

Explicitly destroy the lock.

Implements ACE_Lock.

◆ tryacquire()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::tryacquire ( )
virtual

Release the lock.

Implements ACE_Lock.

◆ tryacquire_read()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::tryacquire_read ( )
virtual

Release the lock.

Implements ACE_Lock.

◆ tryacquire_write()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::tryacquire_write ( )
virtual

Release the lock.

Implements ACE_Lock.

◆ tryacquire_write_upgrade()

template<class ACE_LOCKING_MECHANISM>
int ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::tryacquire_write_upgrade ( )
virtual

Release the lock.

Implements ACE_Lock.

Member Data Documentation

◆ acquire_method_

template<class ACE_LOCKING_MECHANISM>
ACE_Acquire_Method::METHOD_TYPE ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::acquire_method_
private

This indicates what kind of acquire method will be called.

◆ lock_

template<class ACE_LOCKING_MECHANISM>
ACE_LOCKING_MECHANISM& ACE_Reverse_Lock< ACE_LOCKING_MECHANISM >::lock_
private

The concrete locking mechanism that all the methods delegate to.


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