init(value:)
Creates new counting semaphore with an initial value.
Declaration
init(value: Int)Parameters
- value:
The starting value for the semaphore. Do not pass a value less than zero.
Return Value
The newly created semaphore.
Discussion
Passing 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.