From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 15174BC69 for ; Tue, 10 Apr 2007 06:15:42 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3A4Fdq3018350 for ; Tue, 10 Apr 2007 06:15:41 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.7/8.13.7) with ESMTP id l3A4Fc3I002451; Tue, 10 Apr 2007 13:15:38 +0900 (JST) Date: Tue, 10 Apr 2007 13:15:33 +0900 (JST) Message-Id: <20070410.131533.92584169.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 From: Jacques Garrigue In-Reply-To: References: <20070410.100759.08076654.garrigue@math.nagoya-u.ac.jp> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 461B0F6B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; macos:01 threads:01 async:01 async:01 opentk:01 threads:01 ocaml:01 queued:98 caml-list:01 int:01 string:02 garrigue:03 garrigue:03 jacques:03 jacques:03 From: "Jeffrey Loren Shaw" > 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