dispatch_ semaphore_ Grand central dispatch of create – lvalue parameter?
•
Java
In dispatch_ semaphore_ In create, what does the long value parameter mean?
dispatch_semaphore_create(long value)
I don't see this in the documentation, only examples of its use with zero parameters
Solution
The value parameter is the initial value of the count semaphore
dispatch_ semaphore_ Wait() decrements the semaphore count and waits for the result value to be less than 0 (that is, you can call dispatch_semaphore_wait four times without waiting for a semaphore created with a value of 4)
dispatch_ semaphore_ Signal() increments the semaphore count and wakes up the attendant when the result value is less than or equal to 0
For typical usage examples (managing a limited resource pool), see dispatch_ semaphore_ Create (3) online help page
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码