Module GtkThread
val main : unit -> unitThe main loop to use with threads.
GMain.maindoes not work! This changesGMain.mainto callthreaded_mainrather thanGtkMain.Main.default_main, so subsequent calls will work. The first call sets the GUI thread, and subsequent calls tomainwill be automatically routed throughsync. With system threads, the ocaml giant lock is now released on polling, so that other ocaml threads can run without busy wait.Setting
busy_waitingtotrueforces the main loop to be non-blocking. This is required with VM threads. The default value is set totrueat startup if the environment variableLABLGTK_BUSY_WAITis set to something other than0.
val busy_waiting : bool Stdlib.refSetting
busy_waitingtotrueforces the main loop to be non-blocking. This is required with VM threads. The default value is set totrueat startup if the environment variableLABLGTK_BUSY_WAITis set to something other than0.Start the main loop in a new GUI thread. Do not use recursively. Do not use with the Quartz backend, as the GUI must imperatively run in the main thread.
val start : unit -> Thread.tStart the main loop in a new GUI thread. Do not use recursively. Do not use with the Quartz backend, as the GUI must imperatively run in the main thread.
The real main function
val thread_main : unit -> unitThe real main function
Forget the current GUI thread. The next call to
mainwill register its caller as GUI thread.
val reset : unit -> unitForget the current GUI thread. The next call to
mainwill register its caller as GUI thread.
val async : ('a -> unit) -> 'a -> unitAdd an asynchronous job (to do in the main thread)
Add a synchronous job (to do in the main thread)
val sync : ('a -> 'b) -> 'a -> 'bAdd a synchronous job (to do in the main thread)
Whether it is safe to call most GTK functions directly from the current thread
val gui_safe : unit -> boolWhether it is safe to call most GTK functions directly from the current thread
Allow other threads to run, and process the message queue. The following ensures that messages will be processed even if another main loop is running:
Glib.Timeout.add ~ms:100 ~callback:GtkThread.do_jobs