Function

dispatch_semaphore_wait

Waits for (decrements) a semaphore.

Declaration

long dispatch_semaphore_wait(dispatch_semaphore_t dsema, dispatch_time_t timeout);

Parameters

dsema

The semaphore. This parameter cannot be NULL.

timeout

When to timeout (see dispatch_time). The constants DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER are available as a convenience.

Return Value

Returns zero on success, or non-zero if the timeout occurred.

Discussion

Decrement the counting semaphore. If the resulting value is less than zero, this function waits for a signal to occur before returning.