[dmd-concurrency] draft 4
Robert Jacques
sandford at jhu.edu
Tue Jan 12 15:30:50 PST 2010
On Tue, 12 Jan 2010 17:00:22 -0500, Andrei Alexandrescu
<andrei at erdani.com> wrote:
>> I know this is a bit of a bike shed, but I'd prefer something shorter
>> for receiveOnly, (like recv or receive) as A) type-checked message
>> passing should be the easy/default way to do things and B) it's easy to
>> define recv!()() to return the unchecked message using a variant. I'd
>> also like to be able to use recv(tid,i); in addition to recv!(Tid,
>> int)(); but I haven't been able to get the templates to not clash with
>> each other.
>
> As of now I'm thinking that receiveOnly will be much more rarely used
> than receive() with several dispatchers. receiveOnly is very restrictive
> - see my next message.
>
>
> Andrei
The concept for a receive with many dispatchers has a well know name in
CSP parlance: the alternative, alt or select (depending on which
iteration/language you're in) with a set of associated guard statements.
From some old notes I had on doing CSP in D:
select.roundRobin(
guard(id_1, (int x) { writefln("from id 1: ",x);} ),
guard(id_2, (int y) { writefln("from id 2: ",y);} ),
guard(true, { writefln("boolean tests are allowed"); } )
);
Although why they didn't just reuse switch and case I don't know.
More information about the dmd-concurrency
mailing list