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

System.Semaphore.Internal.Version

Description

Semaphore protocol version and versioned semaphore identifiers.

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: a serialised SemaphoreName used for inter-process communication (e.g. as a command line argument).

The specific format of this name string depends on the protocol version:

  • For version 1, this is the unadorned semaphore name.
  • For version N >= 2, the semaphore name is prefixed with v<N>-.

newtype SemaphoreProtocolVersion Source #

The semaphore protocol version currently being used.

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).

data SemaphoreError Source #

Errors that can occur when creating or opening a semaphore.

Constructors

SemaphoreAlreadyExists

Can't create a semaphore: a semaphore with this name already exists.

SemaphoreDoesNotExist

Can't open a semaphore: no semaphore with this name exists.

SemaphoreIncompatibleVersion

Protocol version incompatibility: the semaphore identifier uses a different protocol version than the library is currently using.

SemaphoreOtherError

An IOException was raised when creating or opening the semaphore.

semaphoreVersion :: SemaphoreProtocolVersion Source #

The protocol version used on this host platform with this version of semaphore-compat.

See SemaphoreProtocolVersion.

semaphoreIdentifier :: SemaphoreName -> SemaphoreIdentifier Source #

The serialised identifier of a SemaphoreName for inter-process communication.

See SemaphoreIdentifier for more information.

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).