base-4.7.0.2: 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 | Trustworthy
Language | Haskell2010

Control.Concurrent.QSem

Contents

- Simple Quantity Semaphores

Description

Simple quantity semaphores.

Synopsis

- data QSem
- newQSem :: Int -> IO QSem
- waitQSem :: QSem -> IO ()
- signalQSem :: QSem -> IO ()

# Simple Quantity Semaphores

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.

newQSem :: Int -> IO QSem

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