Function

dispatch_semaphore_create

Creates new counting semaphore with an initial value.

Declaration

dispatch_semaphore_t dispatch_semaphore_create(long value);

Parameters

value

The starting value for the semaphore. Do not pass a value less than zero.

Return Value

The newly created semaphore.

Discussion

Passing zero for the value is useful for when two threads need to reconcile the completion of a particular event. Passing a value greater than zero is useful for managing a finite pool of resources, where the pool size is equal to the value.

See Also

Creating a Semaphore

dispatch_semaphore_t

A dispatch semaphore object.