HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulesemaphore-compat-1.0.0Haskell2010

System.Semaphore

  • 4 types
  • 11 values

System semaphores

13 declarations
valuecreateSemaphore
  1. :: SemaphoreName
  2. -> Int

    number of tokens on the semaphore

  3. -> IO Semaphore
#

Create a new semaphore with the given name and initial amount of available resources.

Throws an error if a semaphore by this name already exists.

valuefreshSemaphore
  1. :: String

    prefix

  2. -> Int

    number of tokens on the semaphore

  3. -> IO Semaphore
#

Create a fresh semaphore with the given amount of tokens.

Its name will start with the given prefix, but will have a random suffix appended to it.

Query the current semaphore value (how many tokens it has available).

This is mainly for debugging use, as it is easy to introduce race conditions when nontrivial program logic depends on the value returned by this function.

Abstract semaphores

2 declarations