base-4.8.2.0: Basic libraries

Copyright | (c) The University of Glasgow 2001
License | BSD-style (see the file libraries/base/LICENSE)
Maintainer | libraries@haskell.org
Stability | experimental
Portability | non-portable (concurrency)
Safe Haskell | Safe
Language | Haskell2010

Control.Concurrent.QSemN

Contents

- General Quantity Semaphores

Description

Quantity semaphores in which each thread may wait for an arbitrary "amount".

Synopsis

- data QSemN
- newQSemN :: Int -> IO QSemN
- waitQSemN :: QSemN -> Int -> IO ()
- signalQSemN :: QSemN -> Int -> IO ()

# General Quantity Semaphores

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.

newQSemN :: Int -> IO QSemN

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`.