Date: Tue, 16 Mar 1999 17:32:29 GMT
From: William Chesters <email@example.com>
Subject: Re: threads & OCamlTK
> And, on a vaguely related topic, is it possible to use threads with
> programs that also use OCamlTK? I know Tk is not threadsafe, but if
> only one thread is calling Tk functions, then perhaps it's still OK?
No, `Tk.mainLoop' blocks the whole process.
To get around this, I have a little module that forks and uses
marshalling to communicate GUI code you want executed to the child
process which is running `Tk.mainLoop'. This can be done in a
let tkDo =
TkServer.fork (fun topLevel ->
Canvas.create topLevel 0 0 400 400, ref )
tkDo (fun canvas, representation ->
representation := Canvas.create_text canvas ...)
It is not too inconvenient as long as you don't worry too much about
efficiency (I think my program ends up sending rather big marshalled
closures across the IPC).
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:21 MET