[dmd-concurrency] Defining shared delegates

Andrei Alexandrescu andrei at erdani.com
Tue Jan 19 21:04:28 PST 2010


Sean Kelly wrote:
> On Jan 19, 2010, at 7:14 PM, Andrei Alexandrescu wrote:
> 
>> Robert Jacques wrote:
>>
>>> As for draft comments, spawn shouldn't be returning a thread id, it should be returning a message box id, because message passing won't be limited to OS threads, so your examples shouldn't imply that it is.
>> Actually it's good as it is. The types of messages accepted by threads are different from those accepted by processes.
> 
> the important thing is that the returned type is always the same.  I suggested Cid (for context id) instead of Tid, but it may be a bit vague.  The way the message passing API is implemented right now for in-process messaging only is:
> 
> struct Cid
> {
> private:
>     Mailbox mbox;
>     this(Mailbox m) { mbox = m; }
> }
> 
> ie. it's completely opaque.  Once inter-process messaging is added, Cid will probably get some more fields.

Nononono, what we need is _specifically_ a Thread ID because we can pass 
certain data (e.g. shared objects) only to threads. Indeed we do need a 
Cid later on, and calling send(cid, ...stuff...) will obey different 
limitations.

I do agree that at some point you can convert a Tid into a Cid and use 
it generically without caring exactly how concurrency is effected. But 
of course then you lose the ability of passing shared data.

Andrei


More information about the dmd-concurrency mailing list