If you can read this text, it means you are not experiencing this website at its best. This website is designed for used with a standards-compliant browser.
Current version: 2.3.2
ZThreads
A platform-independent, multi-threading and synchronization library for C++
Home Documentation Downloads CVS Contact
RecursiveMutex Class Reference

#include <RecursiveMutex.h>

Inheritance diagram for RecursiveMutex:
Lockable NonCopyable

Public Member Functions

 RecursiveMutex ()
 Create a new RecursiveMutex.
 
virtual ~RecursiveMutex ()
 Destroy this RecursiveMutex.
 
virtual void acquire ()
 
virtual bool tryAcquire (unsigned long timeout)
 
virtual void release ()
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 Destroy a Lockable object.
 
virtual void acquire ()=0
 
virtual bool tryAcquire (unsigned long timeout)=0
 
virtual void release ()=0
 

Detailed Description

Author
Eric Crahen http://www.code-foo.com
Date
<2003-07-16T17:51:33-0400>
Version
2.2.1

A RecursiveMutex is a recursive, MUTual EXclusion Lockable object. It is
recursive because it can be acquire()d and release()d more than once by the same thread, instead of causing a Deadlock_Exception.

See also
Mutex
Guard

Scheduling

Threads competing to acquire() a Mutex are granted access in FIFO order.

Error Checking

A Mutex will throw an InvalidOp_Exception if an attempt to release() a Mutex is made from the context of a thread that does not currently own that Mutex.

Member Function Documentation

◆ acquire()

virtual void acquire ( )
virtual

Acquire a RecursiveMutex, possibly blocking until the the current owner of the releases it or until an exception is thrown.

Only one thread may acquire the RecursiveMutex at any given time. The same thread may acquire a RecursiveMutex multiple times.

Exceptions
Interrupted_Exceptionthrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending any wait.
Postcondition
the calling thread successfully acquire ed RecursiveMutex only if no exception was thrown.
See also
Lockable::acquire()

Implements Lockable.

◆ release()

virtual void release ( )
virtual

Release exclusive access. No safety or state checks are performed.

Precondition
This should not be called more times than the acquire() method was called.
See also
Lockable::release()

Implements Lockable.

◆ tryAcquire()

virtual bool tryAcquire ( unsigned long  timeout)
virtual

Acquire a RecursiveMutex, possibly blocking until the the current owner releases it, until an exception is thrown or until the given amount of time expires.

Only one thread may acquire the RecursiveMutex at any given time. The same thread may acquire a RecursiveMutex multiple times.

Parameters
timeoutmaximum amount of time (milliseconds) this method could block
Returns
  • true if the lock was acquired
  • false if the lock was acquired
Exceptions
Interrupted_Exceptionthrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending any wait.
Postcondition
the calling thread successfully acquired RecursiveMutex only if no exception was thrown.
See also
Lockable::tryAcquire(unsigned long timeout)

Implements Lockable.


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