Safe Haskell | Safe-Inferred |
---|
- data Latch
- newLatch :: IO Latch
- withLatchOn :: Latch -> IO a -> IO a
- whenLatch :: Bool -> Latch -> IO () -> IO ()
- whenLatchOff :: Latch -> IO () -> IO ()
- whenLatchOn :: Latch -> IO () -> IO ()
Documentation
A binary switch that is off unless held on during the execution of some IO process. The state of a latch can be read at any time, but can be held on by at most one thread at a time.
withLatchOn :: Latch -> IO a -> IO aSource
Flips the latch on, executes the action, and finally flips the latch off again (even if the action throws an exception). A latch may be held on by at most one thread at a time. If a second thread tries to turn the latch on, it will block.
whenLatch :: Bool -> Latch -> IO () -> IO ()Source
Executes an action only when the latch is on (if given true) or off (if given false).
whenLatchOff :: Latch -> IO () -> IO ()Source
Executes an action only when a latch is off.
whenLatchOn :: Latch -> IO () -> IO ()Source
Executes an action only when a latch is on.