我正在寻找类似于Semaphore
的东西,但在所有插槽都释放后解析。
像这样的东西:
use semaphore = new SemaphoreSlim(0,100)
anEvent.add(fun _ -> semaphore.Release(1) |> ignore);
async {
do! thingThatCausesAnEventToFire100Times()
//where 100 is the available slots instead of the timeout.
let! thingsHappened = semaphore.WaitAsync(100) |> Async.AwaitTask
thingsHappened |> should be True
}
SemaphoreSlim
的MSDN中可以看到:“表示轻量级的替代信号量,它限制了能够同时访问资源或资源池的__线程__数量。” - albertjanSemaphore
并不能解决我的问题 :)。对于 refcount 锁 manualresetevent 路径,我需要状态。这是我迄今为止成功避免的 :)。 - albertjan