Entire Class Index | Main Class Index | Cross Index | Global Index

# Class CL_Mutex

Mutex interface.
Contained in: global
Derived from: none
Derived by: none
Group: Core (System)

#include <ClanLib/core.h>

### public function member index:
### Construction:
``static` `CL_Mutex`*` | `create` | `()`;
`` | `CL_Mutex` | `()`;
`` | `~CL_Mutex` | `()`;
### Operations:
``void`` | `enter` | `()`;
``void`` | `leave` | `()`;
``void`` | `wait` | `()`;
``void`` | `notify` | `()`;
``void`` | `notify_all` | `()`;
### private function member index:
`` | `CL_Mutex` | `(`const` `CL_Mutex`& `copy`)`;
``void`` | `operator``=` | `(`const` `CL_Mutex`& `copy`)`;

## Description:

If you don't know what a mutex is, read a book. :-)

## Function Member Descriptions:

CL_Mutex::CL_Mutex - Construct a new mutex.
`` `CL_Mutex``()`;

CL_Mutex::create - Call this to create a mutex. (provided for 0.4 backward compatibility)
``static` `CL_Mutex`*` `create``()`;

CL_Mutex::enter - Enter the critical section.
``void`` `enter``()`;

CL_Mutex::leave - Leave the critical section.
``void`` `leave``()`;

CL_Mutex::notify - Notify wakes up the first thread that has gone to sleep on this mutex in order to wait for a notification.
For safety reasons, you are advised to acquire the mutex using 'enter' before calling notify. (Of course you have to release the mutex using 'leave' after notifying, otherwise the waiting thread cannot reacquire it).
Warning: Not implemented under Win32. If you need it, please implement it in Sources/Core/System/Win32/mutex_win32.*, and send me the patch. :-)
``void`` `notify``()`;

CL_Mutex::notify_all - NotifyAll wakes up all threads waiting on the mutex.
Warning: Not implemented under Win32. If you need it, please implement it in Sources/Core/System/Win32/mutex_win32.*, and send me the patch. :-)
See also: CL_Mutex::notify
``void`` `notify_all``()`;

CL_Mutex::wait - wait releases the mutex this thread has taken out and sends the thread to sleep.
Other threads can then acquire the mutex and modify any data. When another thread calls notify, the thread that called wait will wake up again and automatically reacquire the mutex.
Warning: This function must not be called on an unlocked mutex. You must call enter first.
Warning: When wait returns (after another thread has called notify/notifyAll, the current thread will have a mutex lock. Be sure to call leave at some point.
Warning: Not implemented under Win32. If you need it, please implement it in Sources/Core/System/Win32/mutex_win32.*, and send me the patch. :-)
``void`` `wait``()`;

CL_Mutex::~CL_Mutex - Destroy mutex.
`` `~CL_Mutex``()`;

## Variable Member Descriptions: