summaryrefslogtreecommitdiffstats
path: root/otherlibs/labltk/support
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/labltk/support')
-rw-r--r--otherlibs/labltk/support/Makefile6
-rw-r--r--otherlibs/labltk/support/tkthread.ml4
-rw-r--r--otherlibs/labltk/support/tkthread.mli12
3 files changed, 12 insertions, 10 deletions
diff --git a/otherlibs/labltk/support/Makefile b/otherlibs/labltk/support/Makefile
index 1fb848bc2..3e315bfc3 100644
--- a/otherlibs/labltk/support/Makefile
+++ b/otherlibs/labltk/support/Makefile
@@ -34,9 +34,9 @@ install: lib$(LIBNAME).a $(PUB)
installopt: opt
@if test -d $(INSTALLDIR); then : ; else mkdir $(INSTALLDIR); fi
cp $(PUBMLI:.mli=.cmx) $(INSTALLDIR)
- if test -f tkthread.o; then \
- cp tkthread.o $(INSTALLDIR); \
- chmod 644 $(INSTALLDIR)/tkthread.o; \
+ if test -f tkthread.cmx; then \
+ cp tkthread.cmx tkthread.o $(INSTALLDIR); \
+ chmod 644 $(INSTALLDIR)/tkthread.cmx $(INSTALLDIR)/tkthread.o; \
fi
clean :
diff --git a/otherlibs/labltk/support/tkthread.ml b/otherlibs/labltk/support/tkthread.ml
index 0336afe3c..04dcc74c5 100644
--- a/otherlibs/labltk/support/tkthread.ml
+++ b/otherlibs/labltk/support/tkthread.ml
@@ -26,7 +26,7 @@ let cannot_sync () =
| Some id -> Thread.id (Thread.self ()) = id
let gui_safe () =
- not (Sys.os_type = "Win32") || !loop_id = Some(Thread.id (Thread.self ()))
+ !loop_id = Some(Thread.id (Thread.self ()))
let has_jobs () = not (with_jobs Queue.is_empty)
let n_jobs () = with_jobs Queue.length
@@ -52,9 +52,9 @@ let rec job_timer () =
let thread_main () =
try
+ loop_id := Some (Thread.id (Thread.self ()));
ignore (Protocol.openTk());
job_timer();
- loop_id := Some (Thread.id (Thread.self ()));
Protocol.mainLoop();
loop_id := None;
with exn ->
diff --git a/otherlibs/labltk/support/tkthread.mli b/otherlibs/labltk/support/tkthread.mli
index ae031e3a4..88883a5db 100644
--- a/otherlibs/labltk/support/tkthread.mli
+++ b/otherlibs/labltk/support/tkthread.mli
@@ -14,7 +14,8 @@
(* $Id$ *)
-(* Basic functions *)
+(* 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
@@ -24,8 +25,8 @@ val thread_main : unit -> unit
val top : Widget.toplevel Widget.widget
(* Jobs are needed for Windows, as you cannot do GUI work from
- another thread.
- Even under Unix some calls need to come from the main thread.
+ 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).
@@ -36,6 +37,7 @@ val top : Widget.toplevel Widget.widget
val async : ('a -> unit) -> 'a -> unit
(** Add a synchronous job (to do in the main thread) *)
val sync : ('a -> 'b) -> 'a -> 'b
-(** Whether it is safe to call most Tk functions directly from
- the current thread *)
+(** 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