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

Safe Haskell | None
Language | Haskell2010

UnliftIO.QSem

Description

Unlifted Control.Concurrent.QSem.

Since: 0.2.14

Synopsis

- data QSem
- newQSem :: MonadIO m => Int -> m QSem
- waitQSem :: MonadIO m => QSem -> m ()
- signalQSem :: MonadIO m => QSem -> m ()
- withQSem :: MonadUnliftIO m => QSem -> m a -> m a

# Documentation

data QSem #

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

Lifted `newQSem`.

Since: 0.2.14

waitQSem :: MonadIO m => QSem -> m () #

Lifted `waitQSem`.

Since: 0.2.14

signalQSem :: MonadIO m => QSem -> m () #

Lifted `signalQSem`.

Since: 0.2.14

withQSem :: MonadUnliftIO m => QSem -> m a -> m a #

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

Since: 0.2.14