concurrency-1.11.0.3: Typeclasses, functions, and data types for concurrency and STM.
Copyright(c) 2016 Michael Walker
LicenseMIT
MaintainerMichael Walker <mike@barrucadu.co.uk>
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.Classy.QSem

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.

Since: 1.0.0.0

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

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

Since: 1.0.0.0

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

Wait for a unit to become available.

Since: 1.0.0.0

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

Signal that a unit of the QSem is available.

Since: 1.0.0.0