Main Page Namespace List Class Hierarchy Compound List Compound Members

# ZThread::Lockable Class Reference

`#include <Lockable.h>`

Inheritance diagram for ZThread::Lockable::

List of all members.

## Public Methods
virtual void | release ()=0 throw (Synchronization_Exception)
virtual void | acquire ()=0 throw (Synchronization_Exception)
virtual bool | tryAcquire (unsigned long)=0 throw (Synchronization_Exception)

## Detailed Description

Author:
  Eric Crahen

Version:
  1.2.1

Date:
  09-21-2001

Abstract base class that defines a lockable interface. Concrete implementations of this class provide various synchronization strategies.

Literature on this subject often refers to P() & V() functions; these functions map to this class type as shown below.

P() => acquire() : Acquire a lock V() => release() : Release a lock

The meaning of these phrases can vary from implementation to implementation. For instance, acquire a lock on a mutex means you have exclusive control of that lock. Acquiring a lock on a semaphore means you have acquired a permit and do not necessarily have exclusive control of the object.

All of these methods can possibly block the calling thread for some period of time. This depends on the implementation, so you should assume that a call will block unless you know that the specific Lockable implementation won't block.

## Member Function Documentation

void acquire ( | ) throw (Synchronization_Exception)`[pure virtual]`

  | P() - Acquire Acquire a lock. Exceptions:
  Synchronization_Exception | - thrown if some error occurs, see the concrete implementation documents for an accurate description of the error
Postcondition: - If no exception occurs, a lock is 'acquired' by the calling thread. Reimplemented in ZThread::Barrier, ZThread::CheckedMutex, ZThread::CountingSemaphore, ZThread::Latch, ZThread::Mutex, ZThread::NullMutex, ZThread::PlainMutex, ZThread::FastMutex, ZThread::FastRecursiveMutex, ZThread::RecursiveMutex, ZThread::WLock, ZThread::RLock, and ZThread::Semaphore.

void release ( | ) throw (Synchronization_Exception)`[pure virtual]`

  | V() - Release Release a lock. If an exception is thrown the state of this object is not altered. Exceptions:
  Synchronization_Exception | - thrown if some error occurs, see the concrete implementation documents for an accurate description of the error
Postcondition: - If no exception occurs, a lock is 'released ' by the calling thread. Reimplemented in ZThread::Barrier, ZThread::CheckedMutex, ZThread::CountingSemaphore, ZThread::Latch, ZThread::Mutex, ZThread::NullMutex, ZThread::PlainMutex, ZThread::FastMutex, ZThread::FastRecursiveMutex, ZThread::RecursiveMutex, ZThread::WLock, ZThread::RLock, and ZThread::Semaphore.

bool tryAcquire ( | unsigned long milliseconds ) throw (Synchronization_Exception)`[pure virtual]`

  | P() - Acquire Acquire a lock. Parameters:
  unsigned | long - amount of time (milliseconds) to spend in an attempt to acquire a lock.
  Returns: bool - success of operation, true if a lock was acquired, false if it was not Exceptions:
  Synchronization_Exception | - thrown if some error occurs, see the concrete implementation documents for an accurate description of the error
  Postcondition: - If no exception occurs, a lock is 'acquired' by the calling thread. Parameters:
  milliseconds |
Reimplemented in ZThread::Barrier, ZThread::CheckedMutex, ZThread::CountingSemaphore, ZThread::Latch, ZThread::Mutex, ZThread::NullMutex, ZThread::PlainMutex, ZThread::FastMutex, ZThread::FastRecursiveMutex, ZThread::RecursiveMutex, ZThread::WLock, ZThread::RLock, and ZThread::Semaphore.

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

- Lockable.h