Blame support/tkthread.mli

Packit bd2e5d
(***********************************************************************)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(*                 MLTk, Tcl/Tk interface of OCaml                     *)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(*         Jacques Garrigue, Nagoya University Mathematics Dept.       *)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(*  Copyright 2004 Institut National de Recherche en Informatique et   *)
Packit bd2e5d
(*  en Automatique and Kyoto University.  All rights reserved.         *)
Packit bd2e5d
(*  This file is distributed under the terms of the GNU Library        *)
Packit bd2e5d
(*  General Public License, with the special exception on linking      *)
Packit bd2e5d
(*  described in file LICENSE found in the OCaml source tree.          *)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(***********************************************************************)
Packit bd2e5d
Packit bd2e5d
(* $Id$ *)
Packit bd2e5d
Packit bd2e5d
(** Helper functions for using LablTk with threads.
Packit bd2e5d
   To use, add tkthread.cmo or tkthread.cmx to your command line *)
Packit bd2e5d
Packit bd2e5d
(** Start the main loop in a new GUI thread. Do not use recursively. *)
Packit bd2e5d
val start : unit -> Thread.t
Packit bd2e5d
Packit bd2e5d
(** The actual function executed in the GUI thread *)
Packit bd2e5d
val thread_main : unit -> unit
Packit bd2e5d
Packit bd2e5d
(** The toplevel widget (an alias of [Widget.default_toplevel]) *)
Packit bd2e5d
val top : Widget.toplevel Widget.widget
Packit bd2e5d
Packit bd2e5d
(** Jobs are needed for Windows, as you cannot do GUI work from
Packit bd2e5d
   another thread. This is apparently true on OSX/Aqua too.
Packit bd2e5d
   And even using X11 some calls need to come from the main thread.
Packit bd2e5d
   The basic idea is to either use async (if you don't need a result)
Packit bd2e5d
   or sync whenever you call a Tk related function from another thread
Packit bd2e5d
   (for instance with the threaded toplevel).
Packit bd2e5d
   With sync, beware of deadlocks!
Packit bd2e5d
*)
Packit bd2e5d
Packit bd2e5d
(** Add an asynchronous job (to do in the GUI thread) *)
Packit bd2e5d
val async : ('a -> unit) -> 'a -> unit
Packit bd2e5d
Packit bd2e5d
(** Add a synchronous job (to do in the GUI thread).
Packit bd2e5d
    Raise [Failure "Tkthread.sync"] if there is no such thread. *)
Packit bd2e5d
val sync : ('a -> 'b) -> 'a -> 'b
Packit bd2e5d
Packit bd2e5d
(** Whether the current thread is the GUI thread.
Packit bd2e5d
    Note that when using X11 it is generally safe to call
Packit bd2e5d
    most Tk functions from other threads too. *)
Packit bd2e5d
val gui_safe : unit -> bool
Packit bd2e5d
Packit bd2e5d
(** Whether a GUI thread is running *)
Packit bd2e5d
val running : unit -> bool