dejafu-0.3.1.1: Overloadable primitives for testable, potentially non-deterministic, concurrency.

Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.Classy.QSem

Contents

Description

Simple quantity semaphores.

Synopsis

Simple Quantity Semaphores

data QSem m Source #

QSem is a quantity semaphore in which the resource is acquired and released in units of one. It provides guaranteed FIFO ordering for satisfying blocked waitQSem calls.

The pattern

bracket_ qaitQSem signalSSem (...)

is safe; it never loses a unit of the resource.

newQSem :: MonadConc m => Int -> m (QSem m) Source #

Build a new QSem with a supplied initial quantity. The initial quantity must be at least 0.

waitQSem :: MonadConc m => QSem m -> m () Source #

Wait for a unit to become available.

signalQSem :: MonadConc m => QSem m -> m () Source #

Signal that a unit of the QSem is available.