]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/otherlibs/labltk/support/tkthread.mli
update
[l4.git] / l4 / pkg / ocaml / contrib / otherlibs / labltk / support / tkthread.mli
1 (***********************************************************************)
2 (*                                                                     *)
3 (*              LablTk, Tcl/Tk interface of Objective Caml             *)
4 (*                                                                     *)
5 (*         Jacques Garrigue, Nagoya University Mathematics Dept.       *)
6 (*                                                                     *)
7 (*  Copyright 2004 Institut National de Recherche en Informatique et   *)
8 (*  en Automatique and Kyoto University.  All rights reserved.         *)
9 (*  This file is distributed under the terms of the GNU Library        *)
10 (*  General Public License, with the special exception on linking      *)
11 (*  described in file LICENSE found in the Objective Caml source tree. *)
12 (*                                                                     *)
13 (***********************************************************************)
14
15 (* $Id: tkthread.mli 8768 2008-01-11 16:13:18Z doligez $ *)
16
17 (* Helper functions for using LablTk with threads.
18    To use, add tkthread.cmo or tkthread.cmx to your command line *)
19
20 (** Start the main loop in a new GUI thread. Do not use recursively. *) 
21 val start : unit -> Thread.t
22 (** The actual function executed in the GUI thread *)
23 val thread_main : unit -> unit
24 (** The toplevel widget (an alias of [Widget.default_toplevel]) *)
25 val top : Widget.toplevel Widget.widget
26
27 (* Jobs are needed for Windows, as you cannot do GUI work from
28    another thread. This is apparently true on OSX/Aqua too.
29    And even using X11 some calls need to come from the main thread.
30    The basic idea is to either use async (if you don't need a result)
31    or sync whenever you call a Tk related function from another thread
32    (for instance with the threaded toplevel).
33    With sync, beware of deadlocks!
34 *)
35
36 (** Add an asynchronous job (to do in the GUI thread) *)
37 val async : ('a -> unit) -> 'a -> unit
38 (** Add a synchronous job (to do in the GUI thread).
39     Raise [Failure "Tkthread.sync"] if there is no such thread. *)
40 val sync : ('a -> 'b) -> 'a -> 'b
41 (** Whether the current thread is the GUI thread.
42     Note that when using X11 it is generally safe to call
43     most Tk functions from other threads too. *)
44 val gui_safe : unit -> bool
45 (** Whether a GUI thread is running *)
46 val running : unit -> bool