## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csSemaphore Class Reference

A semaphore object. More...

`#include <csutil/thread.h>`

Inheritance diagram for csSemaphore:

[legend]
List of all members.

## Public Member Functions

virtual char const * | GetLastError () const =0
| Return the last error description, else 0 if there was none.
virtual bool | LockTry ()=0
| Lock the semaphore if not already locked by some other entity.
virtual bool | LockWait ()=0
| Lock the semaphore.
virtual bool | Release ()=0
| Unlock the semaphore.
virtual uint32 | Value ()=0
| Retrieve the present value of the semaphore.

## Static Public Member Functions

static csRef< csSemaphore > | Create (uint32 value=0)
| Create a semaphore with some initial value.

## Detailed Description

A semaphore object.

Definition at line 228 of file thread.h.

## Member Function Documentation

static csRef<csSemaphore> csSemaphore::Create | ( | uint32 | value = `0` | ) | `[static]`

| Create a semaphore with some initial value.

virtual char const* csSemaphore::GetLastError | ( |  | ) | const`[pure virtual]`

| Return the last error description, else 0 if there was none.

virtual bool csSemaphore::LockTry | ( |  | ) | `[pure virtual]`

| Lock the semaphore if not already locked by some other entity. Does not suspend the thread waiting for the lock. If lock succeeded, returns true. If lock failed, immediately returns false. Each successful call to LockTry() must be balanced with a call to Release().

virtual bool csSemaphore::LockWait | ( |  | ) | `[pure virtual]`

| Lock the semaphore. Suspends execution of the thread until the mutex can be locked. Each LockWait() must be balanced by a call to Release(). Returns true if locking succeeded. Returns false if locking failed for some catastrophic reason; check GetLastError().

virtual bool csSemaphore::Release | ( |  | ) | `[pure virtual]`

| Unlock the semaphore. Each successful call to LockWait() or LockTry() must be balanced by a call to Release(). Returns true if unlocking succeeded. Returns false if unlocking failed for some catastrophic reason; check GetLastError().

virtual uint32 csSemaphore::Value | ( |  | ) | `[pure virtual]`

| Retrieve the present value of the semaphore.

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

- csutil/thread.h