dejafu-0.3.1.1: Overloadable primitives for testable, potentially non-deterministic, concurrency.
Control.Concurrent.Classy.QSemN
Contents
Description
Quantity semaphores in which each thread may wait for an arbitrary "amount".
Synopsis
data QSemN m Source #
QSemN is a quantity semaphore in which the resource is aqcuired and released in units of one. It provides guaranteed FIFO ordering for satisfying blocked waitQSemN calls.
QSemN
waitQSemN
The pattern
bracket_ (waitQSemN n) (signalQSemN n) (...)
is safe; it never loses any of the resource.
newQSemN :: MonadConc m => Int -> m (QSemN m) Source #
Build a new QSemN with a supplied initial quantity. The initial quantity must be at least 0.
waitQSemN :: MonadConc m => QSemN m -> Int -> m () Source #
Wait for the specified quantity to become available
signalQSemN :: MonadConc m => QSemN m -> Int -> m () Source #
Signal that a given quantity is now available from the QSemN.