planet-mitchell-0.1.0: Planet Mitchell

Concurrency.QSem

Contents

Synopsis

QSem

data QSem #

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

The pattern

  bracket_ waitQSem signalQSem (...)

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

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

waitQSem :: QSem -> IO () #

Wait for a unit to become available

signalQSem :: QSem -> IO () #

Signal that a unit of the QSem is available

QSemN

data QSemN #

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.

The pattern

  bracket_ (waitQSemN n) (signalQSemN n) (...)

is safe; it never loses any of the resource.

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

waitQSemN :: QSemN -> Int -> IO () #

Wait for the specified quantity to become available

signalQSemN :: QSemN -> Int -> IO () #

Signal that a given quantity is now available from the QSemN.