From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id D3ECEBCAE for ; Wed, 13 Jul 2005 06:33:36 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6D4XamH029228 for ; Wed, 13 Jul 2005 06:33:36 +0200 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 GAA11577 for ; Wed, 13 Jul 2005 06:33:35 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6D4XXoc029222 for ; Wed, 13 Jul 2005 06:33:34 +0200 Received: from rosella (ppp13-169.lns2.syd3.internode.on.net [59.167.13.169]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id j6D4XQ7i033286; Wed, 13 Jul 2005 14:03:31 +0930 (CST) Subject: Re: [Caml-list] Concurrency for services From: John Skaller To: Christophe TROESTLER Cc: "O'Caml Mailing List" In-Reply-To: <20050713.004043.123299672.Christophe.Troestler@umh.ac.be> References: <20050713.004043.123299672.Christophe.Troestler@umh.ac.be> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-EvDliM/dS43MFGzk8oQ7" Date: Wed, 13 Jul 2005 14:33:32 +1000 Message-Id: <1121229212.27378.23.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 X-Miltered: at concorde with ID 42D499A0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42D4999D.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 christophe:01 troestler:01 callbacks:01 model:01 model:01 threading:01 inverts:01 ocaml:01 ocaml:01 translated:01 threads:01 caching:01 lpd:98 wire:98 X-Attachments: type="application/pgp-signature" name="signature.asc" X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: --=-EvDliM/dS43MFGzk8oQ7 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2005-07-13 at 00:40 +0200, Christophe TROESTLER wrote: > Hi, > Imagine you want to build a server library (e.g. a Lpd daemon, a file > server, a web service,...). In broad terms, you can describe it as a > protocol for which you will handle the various "events" by callbacks. > You do not want to wire any concurrency model in your library but > instead provide the user with the appropriate functions so it can use > his favorite concurrency schema. My question is: what is the best way > to do that? The way the Felix model handles that is: (a) The code is represented by a library which 'reads'=20 abstract events of some type determined by the library. (b) The programmer who is the client of this library is responsible for all scheduling, threading, and I/O. That is, the library leaves the I/O and scheduling "up to the operating system" which the client programmer is required to write. A twist with the Felix model is that the code is written with 'read' commands, but the Felix translator control inverts (twists) the code into event driven code. Actually a version for Ocaml is possible although I haven't tried to create one yet -- Felix targets C++ but it should work for any language which supports classes with virtual functions and switches. [Anyone want to take on an Ocaml back end?] The system generates a class with a 'resume()' method which looks like this in C++ con_t *resume() { switch (pc) { case 1: .... // read variable is translated to this: read=3Dtrue; // flag we need an event read_ptr =3D &variable; // where to deliver it pc =3D 2; // set return address return this; case 2: .... } } An ocaml version would look the same. The point is that the=20 library code incorporates all the abstract business logic, protocol rules etc, but leaves out all the physical I/O and timing issues. I would love to recommend examining Felix package, however there aren't any good examples yet.=20 It was originally designed to run with an existing C++ framework using ACE, ACN, TCAP, and other telephony stuff -- a million lines of C++ code -- where it provided the 'business logic' required by each client (a client being a national telecoms carrier). Examples of business logic rules include 1800, 911, prepaid, conference, and other telephony services and 'products' offered by the client. In this case the processing model used included setting up a database server, plus a multi-CPU Solaris box with a worker thread per CPU, plus a collection of threads to do the event collation, I/O, database caching, load balancing, etc etc etc. --=20 John Skaller Download Felix: http://felix.sf.net --=-EvDliM/dS43MFGzk8oQ7 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBC1Jmaw7vY25tjqN4RArkaAJ4mG2AGZSCEQGCBFPWM+CXL0Q+a7QCeJEiI PPl1fsME4IZTrVwBmhPFME8= =XCxo -----END PGP SIGNATURE----- --=-EvDliM/dS43MFGzk8oQ7--