unix-2.7.0.1: POSIX functionality

Copyright(c) Daniel Franke 2007
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilitynon-portable (requires POSIX)
Safe HaskellTrustworthy
LanguageHaskell2010

System.Posix.Semaphore

Description

POSIX named semaphore support.

Synopsis

Documentation

data OpenSemFlags Source

Constructors

OpenSemFlags 

Fields

semCreate :: Bool

If true, create the semaphore if it does not yet exist.

semExclusive :: Bool

If true, throw an exception if the semaphore already exists.

semOpen :: String -> OpenSemFlags -> FileMode -> Int -> IO Semaphore Source

Open a named semaphore with the given name, flags, mode, and initial value.

semUnlink :: String -> IO () Source

Delete the semaphore with the given name.

semWait :: Semaphore -> IO () Source

Lock the semaphore, blocking until it becomes available. Since this is done through a system call, this will block the *entire runtime*, not just the current thread. If this is not the behaviour you want, use semThreadWait instead.

semTryWait :: Semaphore -> IO Bool Source

Attempt to lock the semaphore without blocking. Immediately return False if it is not available.

semThreadWait :: Semaphore -> IO () Source

Poll the semaphore until it is available, then lock it. Unlike semWait, this will block only the current thread rather than the entire process.

semPost :: Semaphore -> IO () Source

Unlock the semaphore.

semGetValue :: Semaphore -> IO Int Source

Return the semaphore's current value.