From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA05655 for caml-red; Fri, 21 Jul 2000 09:39:33 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA08628 for ; Fri, 21 Jul 2000 04:10:59 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e6L2Avj27021 for ; Fri, 21 Jul 2000 04:10:58 +0200 (MET DST) Received: from localhost (sansho.kurims.kyoto-u.ac.jp [130.54.16.90]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id LAA26540; Fri, 21 Jul 2000 11:10:31 +0900 (JST) To: bskim@ropas.kaist.ac.kr Cc: caml-list@inria.fr Subject: Re: [Q] inter_process communication in CamlTk,OCaml In-Reply-To: Your message of "Fri, 14 Jul 2000 01:04:57 +0900 (KST)" References: X-Mailer: Mew version 1.93 on Emacs 20.5 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20000721111004W.garrigue@kurims.kyoto-u.ac.jp> Date: Fri, 21 Jul 2000 11:10:04 +0900 From: Jacques Garrigue X-Dispatcher: imput version 980905(IM100) Sender: weis@pauillac.inria.fr From: Bomshik Kim > Now I'm making some application with CamlTk and OCaml. > Problem is how to communicate between GUI part and Working part. > > In GUI part, there are start_work button, and stop_work button. > The work is started in a new_process (by fork) by clicking > start_work button. But the work may take a long time > (let's assume 10 min) and raise an exception. > and I want to make the result of work shown on GUI Text. > So GUI part should receive the result from Work part. You might consider using threads. The idea is that you have a main thread running the Tk main loop, and worker threads started by it. They may communicate through mutex or events. CamlTk is not thread safe, so you must be careful about not using any Tk command in your worker threads, since they may cause race conditions. Also, this will not work with bytecode threads (the default) since you won't be able to switch threads once inside the main loop. You have to compile Caml with posix threads instead. I'm no expert in thread programming, so I'm not sure whether what I'm doing is really safe, but this is actually the way the ocamlbrowser subshell works under windows, using a worker thread to read from a pipe (file labltk/browser/shell.ml). Jacques --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG