From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id AB808BB81 for ; Sun, 4 Dec 2005 00:47:24 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB3NlOWk028323 for ; Sun, 4 Dec 2005 00:47:24 +0100 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 AAA22914 for ; Sun, 4 Dec 2005 00:47:23 +0100 (MET) Received: from web34602.mail.mud.yahoo.com (web34602.mail.mud.yahoo.com [209.191.68.136]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id jB3NlMcj007406 for ; Sun, 4 Dec 2005 00:47:23 +0100 Received: (qmail 9367 invoked by uid 60001); 3 Dec 2005 23:47:22 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=wtm1Hmxhtqy6CU/k/1V484kfLjfYL1nlIkmC6Wbyh+Jj5VHv7R3J9Ob9D4iJ7nqwtDApzm1e5slFkPllLC5TPPo+PEz728CQM6gcvfBTR/ID6gphB9MuMU4F5Si50jH1othW8PIjMEwrpOo7R0dnOYkv7FvrTJfvn4+hGJ19P4c= ; Message-ID: <20051203234722.9365.qmail@web34602.mail.mud.yahoo.com> Received: from [69.110.33.39] by web34602.mail.mud.yahoo.com via HTTP; Sat, 03 Dec 2005 15:47:22 PST Date: Sat, 3 Dec 2005 15:47:22 -0800 (PST) From: Ker Lutyn Subject: Are unreachable threads garbage collected? To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 43922E8C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43922E8A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; threads:01 garbage:01 buffered:01 translated:01 ocaml:01 buffered:01 garbage:01 struct:01 rec:01 bbb:98 bbb:98 thread:02 thread:02 module:03 let:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=5.0 tests=FORGED_YAHOO_RCVD autolearn=disabled version=3.0.3 >>From Reppy's paper, an implementation of buffered channels translated to OCaml. Note the internal thread to manage the state. If the buffered channel becomes unreachable, will this thread be garbage collected? module Buffered_channel = struct open Event type 'a t = 'a channel * 'a channel let make () = let i = new_channel () in let o = new_channel () in let rec loop = function | [], [] -> loop ([sync (receive i)], []) | (a :: aa) as aaa, bbb -> select [ wrap (receive i) (fun x -> loop (aaa, x :: bbb)); wrap (send o a) (fun () -> loop (aa, bbb)) ] | [], bbb -> loop (List.rev bbb, []) in ignore (Thread.create loop ([], [])); (i, o) let send (i, _) x = Event.send i x let receive (_, o) = Event.receive o end __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs