semaphore-compat-2.0.0: Cross-platform abstraction for system semaphores
Safe HaskellNone
LanguageHaskell2010

System.Semaphore.Internal.Common

Synopsis

Documentation

data SemaphoreName Source #

A semaphore name: a protocol version and an unversioned name string.

type SemaphoreIdentifier = String Source #

The identifier string of a semaphore, as serialised for transport between processes (e.g. on a command line via -jsem).

For version 1 this is a bare name; for version N (with N >= 2) this is "v<N>-<name>".

semaphoreVersion :: SemaphoreProtocolVersion Source #

The protocol version on this platform.

The version tracks the IPC mechanism, not the library version:

  • POSIX: 2 (domain sockets, replacing v1 system semaphores).
  • Windows: 1 (Win32 named semaphores, unchanged from v1).
  • Unsupported platforms: 0 (no compatible IPC backend).

Because the version is 1 on Windows, semaphoreIdentifier produces a bare name (no v<N>- prefix), matching the v1 format.

semaphoreIdentifier :: SemaphoreName -> SemaphoreIdentifier Source #

The serialised identifier of a SemaphoreName for transport between processes.

For version 1 this is the bare name; for version N (N >= 2) the name is prefixed with v<N>-.

parseSemaphoreIdentifier :: SemaphoreIdentifier -> Maybe SemaphoreName Source #

Parse a SemaphoreIdentifier into a SemaphoreName.

Returns Nothing for unversioned strings (which should be treated as v1 by the caller's compatibility logic).

getSemaphoreSocketPath :: SemaphoreName -> IO FilePath Source #

The socket file path for a semaphore.

iToBase62 :: Int -> String Source #

Convert an Int to a base-62 string (digits 09, az, AZ).