goatee-gtk-0.3.1.2: A monadic take on a 2,500-year-old board game - GTK+ UI.

Safe HaskellNone
LanguageHaskell98

Game.Goatee.Ui.Gtk.Latch

Synopsis

Documentation

data Latch Source #

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.

newLatch :: IO Latch Source #

Creates a new latch that is off.

withLatchOn :: Latch -> IO a -> IO a Source #

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.