Asynchronous concurrency with reference types

Peter Alexander peter.alexander.au at gmail.com
Sat Feb 5 09:45:02 PST 2011


On 4/02/11 11:44 PM, Sean Kelly wrote:
> Peter Alexander Wrote:
>>
>> How would you do it with message passing though? As I understand, all of
>> the std.concurrency message passing routines are blocking, and I need
>> this to be asynchronous.
>
> What do you mean by blocking?  The receive call will block until a message matching one of the supplied types arrives, but if you don't like this you can always use receiveTimeout.  send() doesn't deep copy objects, so the only reference types send() will currently accept are those labeled as shared or immutable (Unique!T will probably be added at some point, which is more appropriate for your situation).  So to use send() known unique reference data you'll have to cast to/from shared or immutable.  Nasty, but it'll work.

That's what I meant by blocking (receive).

Is using receiveTimeout with a timeout of 0 seconds the D-way of 
asynchronous message passing? (seems a bit hacky to me).

Thanks for your reply.


More information about the Digitalmars-d-learn mailing list