XDispatch 0.6.1
Typedefs | Functions
semaphore.h File Reference
#include <dispatch/base.h>

Go to the source code of this file.

Typedefs

typedef struct
dispatch_semaphore_s * 
dispatch_semaphore_t
 A counting semaphore.

Functions

DISPATCH_MALLOC
DISPATCH_NOTHROW
dispatch_semaphore_t 
dispatch_semaphore_create (long value)
 dispatch_semaphore_create
DISPATCH_NONNULL_ALL
DISPATCH_NOTHROW long 
dispatch_semaphore_wait (dispatch_semaphore_t dsema, dispatch_time_t timeout)
 dispatch_semaphore_wait
DISPATCH_NONNULL_ALL
DISPATCH_NOTHROW long 
dispatch_semaphore_signal (dispatch_semaphore_t dsema)
 dispatch_semaphore_signal

Typedef Documentation

A counting semaphore.

Definition at line 35 of file semaphore.h.


Function Documentation

DISPATCH_MALLOC DISPATCH_NOTHROW dispatch_semaphore_t dispatch_semaphore_create ( long  value)

dispatch_semaphore_create

Creates new counting semaphore with an initial value.

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

Parameters:
valueThe starting value for the semaphore. Passing a value less than zero will cause NULL to be returned.
Returns:
The newly created semaphore, or NULL on failure.
DISPATCH_NONNULL_ALL DISPATCH_NOTHROW long dispatch_semaphore_signal ( dispatch_semaphore_t  dsema)

dispatch_semaphore_signal

Signal (increment) a semaphore.

Increment the counting semaphore. If the previous value was less than zero, this function wakes a waiting thread before returning.

Parameters:
dsemaThe counting semaphore. The result of passing NULL in this parameter is undefined.
Returns:
This function returns non-zero if a thread is woken. Otherwise, zero is returned.
DISPATCH_NONNULL_ALL DISPATCH_NOTHROW long dispatch_semaphore_wait ( dispatch_semaphore_t  dsema,
dispatch_time_t  timeout 
)

dispatch_semaphore_wait

Wait (decrement) for a semaphore.

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

Parameters:
dsemaThe semaphore. The result of passing NULL in this parameter is undefined.
timeoutWhen to timeout (see dispatch_time). As a convenience, there are the DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
Returns:
Returns zero on success, or non-zero if the timeout occurred.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Thu Apr 12 2012 09:50:43 for XDispatch by Doxygen 1.7.4
© 2010-2012 MLBA (about | privacy) All Rights reserved.