caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jonathan Bryant <jtbryant@valdosta.edu>
To: Benedikt Grundmann <benedikt@cardexpert.net>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Faking concurrency using Unix forks and pipes (ray tracing results)
Date: Mon, 4 Jun 2007 12:53:04 -0400	[thread overview]
Message-ID: <9BE9B524-35AA-43AC-8A63-4153E3AD672F@valdosta.edu> (raw)
In-Reply-To: <9b415f950706040933r22e1560fhc088368ccb8444fa@mail.gmail.com>


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)


  parent reply	other threads:[~2007-06-04 16:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-04 10:56 Jon Harrop
2007-06-04 15:33 ` [Caml-list] " Jonathan Bryant
2007-06-04 15:39   ` Jonathan Bryant
     [not found]   ` <9b415f950706040850v586a285ax1448d23c0c78a375@mail.gmail.com>
2007-06-04 16:13     ` Jonathan Bryant
     [not found]       ` <9b415f950706040933r22e1560fhc088368ccb8444fa@mail.gmail.com>
2007-06-04 16:53         ` Jonathan Bryant [this message]
2007-06-04 18:00           ` Brian Hurt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9BE9B524-35AA-43AC-8A63-4153E3AD672F@valdosta.edu \
    --to=jtbryant@valdosta.edu \
    --cc=benedikt@cardexpert.net \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).