unliftio-0.2.25.0: The MonadUnliftIO typeclass for unlifting monads to IO (batteries included)

Safe Haskell | None
Language | Haskell2010

UnliftIO.QSemN

Description

Unlifted Control.Concurrent.QSemN.

Since: 0.2.14

Synopsis

- data QSemN
- newQSemN :: MonadIO m => Int -> m QSemN
- waitQSemN :: MonadIO m => QSemN -> Int -> m ()
- signalQSemN :: MonadIO m => QSemN -> Int -> m ()
- withQSemN :: MonadUnliftIO m => QSemN -> Int -> m a -> m a

# Documentation

data QSemN #

`QSemN` is a quantity semaphore in which the resource is acquired 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 :: MonadIO m => Int -> m QSemN #

Lifted `newQSemN`.

Since: 0.2.14

waitQSemN :: MonadIO m => QSemN -> Int -> m () #

Lifted `waitQSemN`.

Since: 0.2.14

signalQSemN :: MonadIO m => QSemN -> Int -> m () #

Lifted `signalQSemN`.

Since: 0.2.14

withQSemN :: MonadUnliftIO m => QSemN -> Int -> m a -> m a #

`withQSemN` is an exception-safe wrapper for performing the provided operation while holding N unit of value from the semaphore. It ensures the semaphore cannot be leaked if there are exceptions.

Since: 0.2.14