interprocess-0.2.1.0: Shared memory and control structures for IPC
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.Process.QSem

Description

Simple interprocess quantity semaphores

Based on POSIX or Win32 C semaphores

Synopsis

Documentation

data QSem Source #

QSem is a quantity semaphore in which the resource is aqcuired and released in units of one.

Instances

Instances details
Eq QSem Source # 
Instance details

Defined in Control.Concurrent.Process.QSem

Methods

(==) :: QSem -> QSem -> Bool #

(/=) :: QSem -> QSem -> Bool #

newQSem :: Int -> IO QSem Source #

Build a new QSem with a supplied initial quantity. The initial quantity must be at least 0.

This function throws an exception if an underlying platform-dependent function fails.

lookupQSem :: SOName QSem -> IO QSem Source #

Lookup QSem by its name in the global namespace. Use this function to init several entangled semaphores in different processes.

This function throws an exception if no QSem with this name exist, or if an underlying platform-dependent function fails.

waitQSem :: QSem -> IO () Source #

Wait for a unit to become available

This function throws an exception if an underlying platform-dependent function fails.

tryWaitQSem :: QSem -> IO Bool Source #

Try to take a unit of the QSem.

This function does not wait, in fact. Sorry for naming.

Returns:

  • True if successfully took a unit of QSem (it is decremented)
  • False if number of available units is less than 1 (it is not decremented)

This function does not throw an exception.

signalQSem :: QSem -> IO () Source #

Signal that a unit of the QSem is available

This function throws an exception if an underlying platform-dependent function fails.

qSemName :: QSem -> SOName QSem Source #

Get a global reference to the semaphore. Send this reference to another process to lookup this semaphore and start interprocess communication.