Browse thread
crash under macos x but not win32
-
Jeffrey Loren Shaw
-
Jacques Garrigue
- skaller
-
Jeffrey Loren Shaw
- Jacques Garrigue
-
Jacques Garrigue
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-04-10 (04:15) |
From: | Jacques Garrigue <garrigue@m...> |
Subject: | Re: [Caml-list] crash under macos x but not win32 |
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