caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* netplex multi-thread asynchronous processor for passive clients
@ 2009-04-03 11:19 Serge Sivkov
  2009-04-03 15:51 ` [Caml-list] " Gerd Stolpmann
  0 siblings, 1 reply; 6+ messages in thread
From: Serge Sivkov @ 2009-04-03 11:19 UTC (permalink / raw)
  To: caml-list

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
?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-05 16:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-03 11:19 netplex multi-thread asynchronous processor for passive clients Serge Sivkov
2009-04-03 15:51 ` [Caml-list] " Gerd Stolpmann
2009-04-03 17:55   ` Serge Sivkov
2009-04-03 18:13     ` Jake Donham
2009-04-04 14:24     ` Serge Sivkov
2009-04-05 16:27       ` Serge Sivkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).