semaphore-compat
Cross-platform abstraction for system semaphores
semaphore-compat
semaphore-compat provides cross-platform semaphores that can be shared across processes.
It uses different backends on different platforms:
- POSIX: Unix domain sockets with automatic return of tokens from disconnected clients.
- Windows: Win32 named semaphores. Tokens held by crashed clients are not returned automatically.
- wasm/JavaScript: buildable stubs that throw unsupported-operation errors. Avoid calling this code on these backends.
It supports:
- Creating server semaphores (
createSemaphore,freshSemaphore).- A server is the process that creates the semaphore and must stay alive for the duration of its use.
- A server process can also act as a client and request/release tokens from the semaphore.
- Opening client semaphores (
openSemaphore). - Waiting with
tryWaitOnSemaphoreor interruptiblewaitOnSemaphore, which returnSemaphoreTokens. - Releasing tokens with
releaseSemaphoreTokenorwithSemaphoreToken. - Destroying semaphores with
destroyClientSemaphoreanddestroyServerSemaphore. - Serialising names and checking versions with
semaphoreIdentifierandversionsAreCompatible.
Install
cabal install semaphore-compat- 2.0.1
- 2.0.0
- 1.0.0