From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA25111; Fri, 14 Sep 2001 00:41:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA25002 for ; Fri, 14 Sep 2001 00:41:31 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f8DMfVP01335 for ; Fri, 14 Sep 2001 00:41:31 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8DMfUn43971 for ; Fri, 14 Sep 2001 00:41:30 +0200 (CEST) Received: from aimlin.ens.fr (root@clipper [129.199.129.1]) by clipper.ens.fr (8.9.2/jb-1.1) id AAA20094 for ; Fri, 14 Sep 2001 00:41:28 +0200 (MET DST) Received: by aimlin.ens.fr (Postfix, from userid 501) id 9AE9F380EB; Fri, 14 Sep 2001 00:04:31 +0200 (CEST) Date: Fri, 14 Sep 2001 00:04:31 +0200 From: Nicolas George To: caml-list@inria.fr Subject: Re: [Caml-list] Timeouts and event Message-ID: <20010914000431.A3510@aimlin> References: <20010913113508.A682@aimlin> <3BA105FB.7500FD0@cmu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.1.4i In-Reply-To: <3BA105FB.7500FD0@cmu.edu>; from ecc@cmu.edu on Thu, Sep 13, 2001 at 03:16:11PM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le jeudi 13 septembre 2001 à 15:16, Eric C. Cooper a écrit : > You can do this nicely using a "watchdog event" that produces a value > after a timeout. Ok, you create a new thread, who will only send the event after the timeout. I am always a bit reluctant in creating new threads, especially if I use system threads. If there were some builtin timeout event, it would be great. And since we are in feature wish, event corresponding to wait_read and wait_write. > let watchdog seconds v = > let channel = Event.new_channel () in > let watchdog_thread () = > Thread.delay seconds; > Event.sync (Event.send channel v) > in > ignore (Thread.create watchdog_thread ()); > Event.receive channel I would write the two last lines like that: let child = Thread.create watchdog_thread () in let event = Event.receive channel in Event.wrap_abort event ~f:(fun () -> Thread.kill child) Aargh, Thread.kill does not exist with system threads! (I see one solution, which is to start a new thread that will only sync the event, but I think it is a waste.) ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr