caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: William Chesters <williamc@dai.ed.ac.uk>
To: caml-list@inria.fr
Subject: Re: threads & OCamlTK
Date: Tue, 16 Mar 1999 17:32:29 GMT	[thread overview]
Message-ID: <13362.199903161732@hobby> (raw)

> 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
type-safe way:

	let tkDo =
	  TkServer.fork (fun topLevel ->
	    Canvas.create topLevel 0 0 400 400, ref [])
        in
	...
	tkDo (fun canvas, representation ->
	  Canvas.delete !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).




             reply	other threads:[~1999-03-17 12:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-16 17:32 William Chesters [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-03-17 15:02 Don Syme
1999-03-17 15:57 ` William Chesters
1999-03-15 15:05 Don Syme
1999-03-16 17:18 ` Francois Rouaix
1999-03-16 17:42   ` Jun P. Furuse
1999-03-22 18:39 ` Trevor Jim
1999-03-22 20:04   ` William Chesters
1999-03-23 16:08     ` Xavier Leroy
1999-03-23 15:07   ` Jerome Vouillon
1999-03-24 17:27     ` William Chesters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13362.199903161732@hobby \
    --to=williamc@dai.ed.ac.uk \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).