File: tkthread.mli

package info (click to toggle)
labltk 8.06.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,972 kB
  • sloc: ml: 12,549; ansic: 1,005; makefile: 578; sh: 289; tcl: 2
file content (51 lines) | stat: -rw-r--r-- 2,314 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(***********************************************************************)
(*                                                                     *)
(*                 MLTk, Tcl/Tk interface of OCaml                     *)
(*                                                                     *)
(*         Jacques Garrigue, Nagoya University Mathematics Dept.       *)
(*                                                                     *)
(*  Copyright 2004 Institut National de Recherche en Informatique et   *)
(*  en Automatique and Kyoto University.  All rights reserved.         *)
(*  This file is distributed under the terms of the GNU Library        *)
(*  General Public License, with the special exception on linking      *)
(*  described in file LICENSE found in the OCaml source tree.          *)
(*                                                                     *)
(***********************************************************************)

(* $Id$ *)

(** Helper functions for using LablTk with threads.
   To use, add tkthread.cmo or tkthread.cmx to your command line *)

(** Start the main loop in a new GUI thread. Do not use recursively. *)
val start : unit -> Thread.t

(** The actual function executed in the GUI thread *)
val thread_main : unit -> unit

(** The toplevel widget (an alias of [Widget.default_toplevel]) *)
val top : Widget.toplevel Widget.widget

(** Jobs are needed for Windows, as you cannot do GUI work from
   another thread. This is apparently true on OSX/Aqua too.
   And even using X11 some calls need to come from the main thread.
   The basic idea is to either use async (if you don't need a result)
   or sync whenever you call a Tk related function from another thread
   (for instance with the threaded toplevel).
   With sync, beware of deadlocks!
*)

(** Add an asynchronous job (to do in the GUI thread) *)
val async : ('a -> unit) -> 'a -> unit

(** Add a synchronous job (to do in the GUI thread).
    Raise [Failure "Tkthread.sync"] if there is no such thread. *)
val sync : ('a -> 'b) -> 'a -> 'b

(** Whether the current thread is the GUI thread.
    Note that when using X11 it is generally safe to call
    most Tk functions from other threads too. *)
val gui_safe : unit -> bool

(** Whether a GUI thread is running *)
val running : unit -> bool