What does the long value parameter signify in dispatch_semaphore_create ?
dispatch_semaphore_create(long value)
I didn't see this in the documentation, only examples of it being used with a zero argument.
The value parameter is the initial value for the counting semaphore.
dispatch_semaphore_wait() decrements the semaphore count and waits if the resulting value is less than 0 (i.e. you can call dispatch_semaphore_wait four times without waiting on a semaphore created with value 4).
dispatch_semaphore_signal() increments the semaphore count and wakes a waiter if the resulting value is less than or equal 0.
See the dispatch_semaphore_create(3) manpage for a typical usage example (managing a finite resource pool).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With