caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: shawjef3@msu.edu
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] crash under macos x but not win32
Date: Tue, 10 Apr 2007 13:15:33 +0900 (JST)	[thread overview]
Message-ID: <20070410.131533.92584169.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <E1Hb7TL-0003FH-Ab@sys29.mail.msu.edu>

From: "Jeffrey Loren Shaw" <shawjef3@msu.edu>
> Thanks for your reply! Inspired by your use of Timer.set in Tkthreads, I 
> decided to use a library I keep handy for queued communication between 
> threads. Using it frees me of having to type sync, async, etc a lot. The 
> only major improvement now would be to make it so that you don't have to 
> poll the queue. I don't know how to do that right now. 

There may be a misunderstanding due to my translation.
You don't have to write a sync or async for each and every Tk function
call. In your example below, you could write

open Tkthread
let tk = start ()

let testthree () =
 let top = openTk () in
 let l = Label.create top in
 let lconfig s () = 
 let qm = createqm () in
 let loopfun () =
   ignore
     (
	Thread.create
	  (fun () ->
	    for i=0 to 5 do
	      Thread.delay 1.;
              async (Label.configure ~text:(string_of_int i)) l
	    done
	  )
	  ()
     )
 in
 let b = Button.create ~text:"Run the test" ~command:loopfun top in
 pack [l];
 pack [b]

let () =
  async testthree ();
  Thread.join tk;
  exit 0

By the way, the polling is needed in order to have threads running
while using the Tk main loop. One could also do the opposite, polling
for Tk events while running an ocaml main loop...

Jacques Garrigue


  reply	other threads:[~2007-04-10  4:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-10  0:19 Jeffrey Loren Shaw
2007-04-10  1:07 ` [Caml-list] " Jacques Garrigue
2007-04-10  2:08   ` skaller
2007-04-10  2:41     ` Jacques Garrigue
2007-04-10  3:56   ` Jeffrey Loren Shaw
2007-04-10  4:15     ` Jacques Garrigue [this message]
2007-04-10  5:52       ` skaller

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=20070410.131533.92584169.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=shawjef3@msu.edu \
    /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).