semaphore.h
IntroductionUse the links in the table of contents to the left to access the documentation. Functions
dispatch_semaphore_createCreates new counting semaphore with an initial value. ( macos( 10.6), ios( 4.0)) DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED dispatch_semaphore_t dispatch_semaphore_create( intptr_t value); ParametersReturn ValueThe newly created semaphore, or NULL on failure. DiscussionPassing 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. dispatch_semaphore_signalSignal (increment) a semaphore. ( macos( 10.6), ios( 4.0)) intptr_t dispatch_semaphore_signal( dispatch_semaphore_t dsema); ParametersReturn ValueThis function returns non-zero if a thread is woken. Otherwise, zero is returned. DiscussionIncrement the counting semaphore. If the previous value was less than zero, this function wakes a waiting thread before returning. dispatch_semaphore_waitWait (decrement) for a semaphore. ( macos( 10.6), ios( 4.0)) intptr_t dispatch_semaphore_wait( dispatch_semaphore_t dsema, dispatch_time_t timeout); ParametersReturn ValueReturns zero on success, or non-zero if the timeout occurred. DiscussionDecrement the counting semaphore. If the resulting value is less than zero, this function waits for a signal to occur before returning. Typedefs
dispatch_semaphore_tA counting semaphore. typedef struct dispatch_semaphore_s *dispatch_semaphore_t; |