Safe Haskell | Safe-Inferred |
---|
This has the FLTK event thread, and communication with it.
Synopsis
- data Fltk a
- fltk :: IO a -> Fltk a
- type Channel = MVar.MVar [(Fltk (), Text)]
- event_loop :: Channel -> QuitRequest -> TChan UiMsg.UiMsg -> IO ()
- send_action :: Channel -> Text -> Fltk () -> IO ()
- quit_ui_thread :: QuitRequest -> IO ()
Documentation
You should only talk to FLTK from the main thread, which is also the FLTK
event thread. So to call a FLTK function, you have to put it on
the UI Channel
, where the FLTK thread will pick it up. This also
serializes them, so I don't have to worry about concurrency at the Fltk
layer. Since FLTK operations are wrapped in Fltk, and only this module can
unwrap a Fltk, this should enforce that you can't cell them willy-nilly.
type Channel = MVar.MVar [(Fltk (), Text)] Source #
Channel to communicate with the FLTK event loop. Yes it's not a real channel, but I want to get all actions in one go, and an MVar is suitable for that.
event_loop :: Channel -> QuitRequest -> TChan UiMsg.UiMsg -> IO () Source #
Run the FLTK event loop thread, passing it a channel that produces msgs, and go into the UI polling loop. This is intended to be run from the main thread, since some UIs don't work properly unless run from the main thread. When the app exits, the ui loop will be aborted.
send_action :: Channel -> Text -> Fltk () -> IO () Source #
Send the UI to the ui thread to run asynchronously.
quit_ui_thread :: QuitRequest -> IO () Source #