Version française
Home     About     Download     Resources     Contact us    
Browse thread
Faking concurrency using Unix forks and pipes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Florian Hars <hars@b...>
Subject: Re: [Caml-list] Faking concurrency using Unix forks and pipes
Jon Harrop schrieb:
> Has anyone implemented a parallel map function in OCaml using Unix forks, 
> pipes and maybe marshalling?

I've been toying with something like

module type MR =
  functor (D1: DICT_TYPE) ->
    functor (D2: DICT_TYPE) ->
sig
  val mapreduce :
    (D1.key -> D1.value -> (D2.key * 'a) list) ->
    ( D2.key -> 'a list -> D2.value option) ->
    D1.t ->
    D2.t
end

and have one implementation that forks a set of worker processes
and then marshalls data of types
type 'a command = Quit | Execute of 'a
type ('a, 'b) response = Result of 'a | Error of 'b
through a pipe.

Not very robust right now, but it seems to work if none of the
workers dies prematurely...

Yours Florian.