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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Bryant <jtbryant@v...>
Subject: Re: [Caml-list] Faking concurrency using Unix forks and pipes (ray tracing results)

On Jun 4, 2007, at 12:33 PM, Benedikt Grundmann wrote:

>
> It looks a bit more complex, but that's just to avoid big strings in
> case of big messages
> (e.g. with the "simple" interface you end up with the "same" content
> in memory twice).

I think big strings are unavoidable in this case.  They can be broken  
up at the protocol level for sending, but a large data structure is  
going to be marshaled into a big string.  As far as same content in  
memory twice, that should be the case for pure values even in a  
regular OCaml program.  As for mutable values, they shouldn't be sent  
over a channel to begin with.  Once channels are available though,  
creating a synchronous mutable cell is only a few lines of code.   
(Check out Reppy's book/papers).

> I'm trying to do something similar, but I'm not 100% sure right now
> that it will all work out exactly as I initially thought.. :-)    You
> can have a look at my current "interface", I already have a prototype
> commited...  src/mailbox.mli is the "main" interface of the library.
> The comments are not totally in sync with the interface right now as
> I'm restructuring a lot these days.

I need to do a commit.  I'm using modules which return a record of  
functions, and you can compose them to get channels that work over  
multiple mediums.

> Okay I'm still a little bit confused how does your Thread.create looks
> like (e.g what is
> its signature)?

Something like:

module Thread =
	struct
		type con_type =
		| Concurrent
		| Parallel
		| Remote

		let create ?(con = Concurrent) f x = (* Create thread *)
		let concurrent f x = create ~con:Concurrent f x
		let parallel f x = create ~con:Parallel f x
		let remote f x = create ~con:Remote f x

		let create_attached ?(con = Concurrent) f x = (* Create thread and  
return event *)
		let concurrent_attached f x = create ~con:Concurrent f x
		let parallel_attached f x = create ~con:Parallel f x
		let remote_attached f x = create ~con:Remote f x

		(* Other thread functions *)
	end

I've implemented a good chunk of channels/events so far, but haven't  
got to the threads yet, so don't quote me on that exact signature.

--Jonathan

>
> Cheers,
>
> Bene
>
> -- 
> Calvin: I try to make everyone's day a little more
> surreal.
>
> (From Calvin & Hobbes)