dispatch_semaphore_create的左值参数?

Jas*_*ues 6 grand-central-dispatch

在dispatch_semaphore_create中,long值参数表示什么?

dispatch_semaphore_create(long value)
Run Code Online (Sandbox Code Playgroud)

我没有在文档中看到这一点,只有它与零参数一起使用的例子.

das*_*das 9

value参数是计数信号量的初始值.

dispatch_semaphore_wait()递减信号量计数并等待结果值小于0(即,您可以调用dispatch_semaphore_wait四次而无需等待使用值4创建的信号量).

dispatch_semaphore_signal() 如果结果值小于或等于0,则递增信号量计数并唤醒服务员.

有关dispatch_semaphore_create(3)典型用法示例(管理有限资源池),请参见联机帮助页.