| Copyright | (c) Sam Derbyshire 2022 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | Sam Derbyshire |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Windows Semaphore objects and operations
A Windows semaphore.
To obtain a Semaphore, use createSemaphore to create a new one, or openSemaphore to open an existing one.
To wait on a semaphore, use waitForSingleObject.
To release resources on a semaphore, use releaseSemaphore.
To free a semaphore, use closeHandle. The semaphore object is destroyed when its last handle has been closed. Closing the handle does not affect the semaphore count; therefore, be sure to call releaseSemaphore before closing the handle or before the process terminates. Otherwise, pending wait operations will either time out or continue indefinitely, depending on whether a time-out value has been specified.
| Semaphore | |
Fields | |
type AccessMode = UINT Source
sEMAPHORE_ALL_ACCESS :: AccessMode Source
sEMAPHORE_MODIFY_STATE :: AccessMode Source
| :: Maybe SECURITY_ATTRIBUTES | |
| -> LONG | initial count |
| -> LONG | maximum count |
| -> Maybe String | (optional) semaphore name (case-sensitive, limited to MAX_PATH characters) |
| -> IO (Semaphore, Bool) |
Open a Semaphore with the given name, or create a new semaphore if no such semaphore exists, with initial count i and maximum count m.
The counts must satisfy i >= 0, m > 0 and i <= m.
The returned Bool is True if the function found an existing semaphore with the given name, in which case a handle to that semaphore is returned and the counts are ignored.
Use openSemaphore if you don't want to create a new semaphore.
| :: AccessMode | desired access mode |
| -> Bool | should child processes inherit the handle? |
| -> String | name of the semaphore to open (case-sensitive) |
| -> IO Semaphore |
Open an existing Semaphore.
releaseSemaphore :: Semaphore -> LONG -> IO LONG Source
Increase the count of the Semaphore by the specified amount.
Returns the count of the semaphore before the increase.
Throws an error if the count would exceeded the maximum count of the semaphore.
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/9.12.1/docs/libraries/Win32-2.14.1.0-d391/System-Win32-Semaphore.html