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 NAA13244; Mon, 29 Mar 2004 13:41:26 +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 NAA14278 for ; Mon, 29 Mar 2004 13:41:25 +0200 (MET DST) Received: from smtp2.su.se (smtp2.su.se [130.237.93.212]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2TBfOHd017299 for ; Mon, 29 Mar 2004 13:41:24 +0200 Received: from localhost (smtp2.su.se [127.0.0.1]) by smtp2.su.se (Postfix) with ESMTP id 38FFC20090D for ; Mon, 29 Mar 2004 13:41:24 +0200 (CEST) Received: from smtp2.su.se ([127.0.0.1]) by localhost (smtp2.su.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19524-01-36 for ; Mon, 29 Mar 2004 13:41:24 +0200 (CEST) Received: from murmeldjur.it.su.se (murmeldjur.it.su.se [130.237.95.79]) by smtp2.su.se (Postfix) with ESMTP id 1A20E20090A for ; Mon, 29 Mar 2004 13:41:24 +0200 (CEST) Received: from murmeldjur.it.su.se (localhost [127.0.0.1]) by murmeldjur.it.su.se (8.12.10/8.12.10) with ESMTP id i2TBfNoP082849 for ; Mon, 29 Mar 2004 13:41:24 +0200 (CEST) (envelope-from rnyberg@it.su.se) Date: Mon, 29 Mar 2004 13:41:23 +0200 Message-ID: From: Richard Nyberg To: caml-list@inria.fr Subject: [Caml-list] lib design questions User-Agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3 (i386--freebsd) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at su.se X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; nyberg:01 rnyberg:01 xmpp:01 threads:01 hub:99 -richard:01 asynchronous:01 ocaml:01 ocaml:01 lib:01 receive:97 receive:97 thread:02 thread:02 library:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Keywords: X-UID: 409 Hello ocaml demi gods :) I'm trying to write a library for a network protocol (xmpp). I thought I could do it with a network of threads and the Event system that ocaml has. The design I have now is like this: [Thread 3] is always running and is kind of a message distribution hub. [Thread 1] and [Thread 2] is created for every connection and are there to read data from the connection and giving full protocol messages to [Thread 3]. [Thread 1] reads data from network send data on ch_1to2 [Thread 2] receive data on ch_1to2 until we have parsed a protocol message send message on ch_2to3 [Thread 3] Select receive protocol messages on ch_2to3 receive servers request on req_ch ... send protocol messages on some channels Question 1: Sometimes it is necessary to replace [Thread 1] and [Thread 2] with a new pair of thread for a connection (startssl and sasl). How can I do that? Is it always safe do do Thread.kill on them? Question 2: Is this design totally idiotic? Do you have design patterns for asynchronous message protocols? Happy hacking! -Richard ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners