Cross-Platform C++

ot
class FastMutex

#include "ot/base/FastMutex.h"

Variety of mutex that is optimized and may offer better performance on some platforms. A mutex can be acquired (locked) by only one thread at a time. A thread should not attempt to acquire a FastMutex that it already owns (see RecursiveMutex if you require this).

While a thread 'owns' the mutex (i.e. has it locked), it can safely use the protected resource, which may be a variable, a region of memory or anything else, in the knowledge that no other thread will be accessing it. However, this only holds true if all threads obey the rules and acquire the mutex before attempting to access the protected resource.

See also:
Mutex , RecursiveMutex



Constructor/Destructor Summary
FastMutex()
         Default constructor.
~FastMutex()
         Destructor.

Method Summary
 void lock()
         Acquires the mutex.
 bool tryLock()
         Attempts to acquire the mutex without blocking.
 void unlock()
         Releases the mutex.

Typedefs

Lock

typedef AutoLock< FastMutex > Lock

Constructor/Destructor Detail

FastMutex

 FastMutex()
Default constructor. Initializes the mutex for use.


~FastMutex

 ~FastMutex()
Destructor. Frees any resources held by the mutex.


Method Detail

lock

void lock()
Acquires the mutex. If the mutex is currently held by another thread this call blocks and waits until the mutex becomes available.

A thread should not attempt to lock a FastMutex that it already owns. This behaviour is undefined for the FastMutex class but is supported by RecursiveMutex.

See also:
tryLock , unlock

tryLock

bool tryLock()
Attempts to acquire the mutex without blocking. This function differs from lock() because it returns immediately even if the mutex is held by another thread.

Returns:
true if the mutex was successfully acquired; false otherwise.
See also:
lock() , unlock()

unlock

void unlock()
Releases the mutex.



Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements