base-4.20.0.1: Core data structures and operations
Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilitystable
Portabilitynon-portable (concurrency)
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Concurrent.QSemN

Description

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

Synopsis

General Quantity Semaphores

data QSemN Source #

QSemN is a quantity semaphore in which the resource is acquired and released in arbitrary amounts. 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 Source #

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

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

Wait for the specified quantity to become available.

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

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