Go to the first, previous, next, last section, table of contents.


Mutex

Lock defines the interface of any object implementing lock and unlock.

Class SafeLock locks its argument's constructor in the constructor itself and unlock it upon deletion. It accepts any Lock instances. This allow a safe lock/unlock balancing call when entering/leaving functions or when exceptions are used. A family of macros (SAFELOCK, SAFELOCK1,...) are defined making its use straightforward and concise.

Mutex is the DEFAULT implementation class whose inherit FastMutex, DebugMutex, RecursiveMutex.


class Lock {
public :
    virtual void lock() = 0;
    virtual void unlock() = 0;
}

class Mutex : public Lock { 
public:
    virtual void lock();
    virtual void unlock();
    virtual CV *createCV();

    static Mutex* create ();
    static void destroy (Mutex*);
}

class FastMutex        : public Mutex;
class RecursiveMutex   : public Mutex;
class DebugMutex       : public Mutex;

Mutex method: Mutex* create ()
Creates and returns a mutex.

Mutex method: void destroy (Mutex* mutex)
Destroys mutex.

Mutex method: Mutex* reify (MUTEX_T mid)
Registers the mutex identified by mid in the raw package and returns its corresponding Mutex instance.

Mutex method: CV* createCV ()
Creates, associates to the invoked mutex and returns a CV. The mutex invoked must not be a RECURSIVE one .

Mutex method: void lock ()
Blocks the calling thread until the mutex is not owned by anyone. If the mutex is a RECURSIVE one, the mutex may be already owned by the calling thread. In that case, there must be as many unlock invocations than there has been lock invocations on this mutex, in order to release it.

Mutex method: void unlock ()
Frees a mutex.

Mutex Assertions


Go to the first, previous, next, last section, table of contents.