HORIZON HASKELLDocslts/ghc-9.14.xb2f3bfd2026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11

Moduleunliftio-0.2.25.1Haskell2010

UnliftIO.QSemN

  • 1 type
  • 4 values
datadata QSemN
#

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.

valuewithQSemN :: 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.