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=2.8 required=5.0 tests=DNS_FROM_RFC_POST,SPF_NEUTRAL 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 63644BBC4 for ; Fri, 3 Apr 2009 13:19:26 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgwDAFeN1UnRVdq0kGdsb2JhbACVYz8BAQEBCQkMBxEDp0aBCJAxAQMBA4JIgUQG X-IronPort-AV: E=Sophos;i="4.39,319,1235948400"; d="scan'208";a="37793044" Received: from mail-bw0-f180.google.com ([209.85.218.180]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Apr 2009 13:19:25 +0200 Received: by bwz28 with SMTP id 28so1038190bwz.27 for ; Fri, 03 Apr 2009 04:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=5QVypCXI6LfQjElFDnHZCx++0iESfxNO5AGjTQ1hOZw=; b=JwjCLWpYsuYB5aBg2ahzuFcvosz8QrbGp+kHL5MCbvuXQXWn7CchEj8/pEj4C9EUYT 6LoqY9Fn2Ml2mCd9eBrhO8ykwTEXt70VB5g4klQMUvX3QrBiR78tUMxxypIvSQfrc++y i4x6sL1Ubijs0pDhU0eEP56p/7vsGtb4fRzfU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=thsJ3m4LRRpRy8MA3zVGZ/VQUoJ4sWEVEBhscKx5hLB/3BQ1s36lb6VeYchAupmXjJ ZylV1rISYEPEq1FsIIn7M6XBzSsqhesbiX1sWTmWhsUTlAg/KIU9vuR6oUHFMX9/3Oty 594GHcY677mZtCe7iAyfhK96kBRht65i+/aME= MIME-Version: 1.0 Received: by 10.204.103.203 with SMTP id l11mr381810bko.71.1238757565472; Fri, 03 Apr 2009 04:19:25 -0700 (PDT) Date: Fri, 3 Apr 2009 17:19:25 +0600 Message-ID: Subject: netplex multi-thread asynchronous processor for passive clients From: Serge Sivkov To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; iter:01 iter:01 sockets:01 sprintf:01 sexp:01 sexp:01 threading:01 multithread:01 workload:01 ssp:98 ideally:01 ideally:01 unix:01 rec:01 int:01 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). 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 ?