A system semaphore (POSIX or Win32).
Modulesemaphore-compat-1.0.0Haskell2010
System.Semaphore
- 4 types
- 11 values
- Packagesemaphore-compat-1.0.0
- Exports15
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceSemaphore.hs
System semaphores
13 declarationsConstructors
Instances1Eq
Eq SemaphoreNameDefined in semaphore-compat-1.0.0 · System.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.
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.
Open a semaphore with the given name.
If no such semaphore exists, throws an error.
Indefinitely wait on a semaphore.
If you want to be able to cancel a wait operation, use forkWaitOnSemaphoreInterruptible instead.
Try to obtain a token from the semaphore, without blocking.
Immediately returns False if no resources are available.
WaitId stores the information we need to cancel a thread which is waiting on a semaphore.
See forkWaitOnSemaphoreInterruptible and interruptWaitOnSemaphore.
Constructors
Spawn a thread that waits on the given semaphore.
In this thread, asynchronous exceptions will be masked.
The waiting operation can be interrupted using the interruptWaitOnSemaphore function.
Interrupt a semaphore wait operation initiated by forkWaitOnSemaphoreInterruptible.
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.
Release a semaphore: add n to its internal counter.
No-op when `n <= 0`.
Destroy the given semaphore.
Abstract semaphores
2 declarationsAbstraction over the operations of a semaphore.
Constructors
AbstractSemacquireSem :: IO ()releaseSem :: IO ()