---
name: "CL_Mutex"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_Mutex"
---

# CL\_Mutex(3)

Mutex interface.

## NAME

CL\_Mutex - Mutex interface.

## DESCRIPTION

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

## CLASS MEMBERS

- static CL\_Mutex \***create**()

  - virtual **~CL\_Mutex**()

  - virtual void **enter**()

  - virtual void **leave**()

  - virtual void **wait**()

  - virtual void **notify**()

  - virtual void **notify\_all**()

  ## MEMBERS WITH DESCRIPTIONS

- static CL\_Mutex \***create**()

  ```
  Description:
  ```

  Call this to create a mutex.

- virtual **~CL\_Mutex**()

  ```
  Description:
  ```

- virtual void **enter**()

  ```
  Description:
  ```

  Enter the critical section.

- virtual void **leave**()

  ```
  Description:
  ```

  Leave the critical section.

- virtual void **wait**()

  ```
  Description:
  ```

  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. :-)

- virtual void **notify**()

  ```
  Description:
  ```

  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. :-)

- virtual void **notify\_all**()

  ```
  Description:
  ```

  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

All ClanLib API classes can be found in **clanlib (3)**.

## AUTHORS

Originally written by Magnus Norddahl \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at **http://somewhere.in.the.world.org**).

See **clanlib (3)** to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.
