libXDispatch 0.5
Functions
include/libdispatch/semaphore.h File Reference

Go to the source code of this file.

Functions

 DISPATCH_DECL (dispatch_semaphore)
__DISPATCH_BEGIN_DECLS
DISPATCH_EXPORT
DISPATCH_MALLOC
DISPATCH_NOTHROW
dispatch_semaphore_t 
dispatch_semaphore_create (long value)
DISPATCH_EXPORT
DISPATCH_NONNULL_ALL
DISPATCH_NOTHROW long 
dispatch_semaphore_wait (dispatch_semaphore_t dsema, dispatch_time_t timeout)
DISPATCH_EXPORT
DISPATCH_NONNULL_ALL
DISPATCH_NOTHROW long 
dispatch_semaphore_signal (dispatch_semaphore_t dsema)

Function Documentation

DISPATCH_DECL ( dispatch_semaphore  )
__DISPATCH_BEGIN_DECLS DISPATCH_EXPORT 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_EXPORT 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_EXPORT 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.

Generated on Wed Feb 22 2012 19:54:05 for libXDispatch by Doxygen 1.7.4
Content © 2011-2012 MLBA (about | privacy) – Design © 2010-2012 Emzeat. All Rights reserved.