From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 04D89BBC4 for ; Fri, 3 Apr 2009 17:49:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjIIAI/M1UnU436raGdsb2JhbACBUpRRDQsDBwcRA7kdAYJKgUQG X-IronPort-AV: E=Sophos;i="4.39,320,1235948400"; d="scan'208";a="37812649" Received: from moutng.kundenserver.de ([212.227.126.171]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Apr 2009 17:49:22 +0200 Received: from office1.lan.sumadev.de (dslb-084-059-070-054.pools.arcor-ip.net [84.59.70.54]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MKv1o-1Lpldw3CGI-000jag; Fri, 03 Apr 2009 17:49:20 +0200 Received: from [192.168.0.32] (dslb-084-059-072-056.pools.arcor-ip.net [84.59.72.56]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 96FC7C0EF3; Fri, 3 Apr 2009 17:48:15 +0200 (CEST) Subject: Re: [Caml-list] netplex multi-thread asynchronous processor for passive clients From: Gerd Stolpmann To: Serge Sivkov Cc: caml-list@yquem.inria.fr In-Reply-To: References: Content-Type: text/plain Date: Fri, 03 Apr 2009 17:51:37 +0200 Message-Id: <1238773897.9723.6.camel@flake.lan.gerd-stolpmann.de> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX19AP2j677dyu9eYG0jtm9NCZ98fo94qxYK0xlE afYUrr72LPzZwxdLeFZYg3RQV7po4B1dqYtANTdDYcubbc/2Ci pM0K4GZ7WJeFc4fZvafuA== X-Spam: no; 0.00; gerd:01 stolpmann:01 gerd:01 iter:01 iter:01 sockets:01 sprintf:01 sexp:01 sexp:01 threading:01 multithread:01 workload:01 stolpmann:01 viktoriastr:01 64293:01 Am Freitag, den 03.04.2009, 17:19 +0600 schrieb Serge Sivkov: > Hello, > I want to convert my synchronious multi process netplex service to > asynchronous multi thread one. > I don't understood how can i send data from #receive_message > to #process for asynchronous worker (ideally more than one per thread). > > Here is my current code : > class my_hooks = > ... > method receive_admin_message container name args = > let s = "admin message to contaner: " ^ name in > container#log `Info s; > let aux (proto,fds) = > Array.iter > (fun fd -> > container#socket_service#processor#process (fun () -> ()) > container fd proto) > fds in > List.iter aux container#socket_service#sockets > > end > > class ts_alfa_processor hooks : Netplex_types.processor = > ... > method process ~when_done container fd proto_name = > let s = > sprintf "process called with %d and %s" (int_of_file_descr fd) > proto_name in > container#log `Info s; > let ch = Unix.out_channel_of_descr fd in > let rec aux () = > let s = (Sexp.to_string (sexp_of_msg dfl_msg)) ^ "\n" in > output_string ch s; > flush ch in (*+aux() for synchronious version *) > aux () > > method supported_ptypes = [ `Multi_processing; `Multi_threading ] > end > > That code doesn't work because method process called from > receive_admin_message got wrong fd as argument (i assume, that's > parent fd used to accept right one). No, that does not work. process must be called from the right environment. > What is the right way to write porcessor which must: > - work asyncroniously with multithread workload manager > (ideally, many jobs per thread) > - work with clients whom don't send any packets > - get data to send from messages sent by other service e.g. open a Unix domain socket, and send data over that socket. Right now, there is no faster way that is officially supported. For convenience, you can define RPC procedures that do all the serialization details. What could work if sender and receiver are on the same event system: The sender puts a special event with the message onto the event queue, and the receiver installs an event handler listening for such events. I don't have demo code for something like this, however. Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------