[dmd-concurrency] Vot de hekk is shared good for, anyway?

Walter Bright walter at digitalmars.com
Sun Jan 10 20:20:07 PST 2010



Graham St Jack wrote:
> I'm happy with things being carefully wrapped and auto-magic. However, 
> surely the message channel (or whatever it is called) object itself 
> will have be shared (and its externally accessible methods 
> synchronized), otherwise we are cheating. We have a object whose sole 
> purpose in life is to be shared by multiple threads, so surely if 
> anything is shared, this one has to be.
>
> If this is the case, then we need a mechanism to stop "shared" from 
> leaking out into the whole code base.
>
> Since no-one ever responds to this line of questioning, it looks like 
> I am missing something fundamental. Can anyone help me out here?
>

Messages are values, not references. Values have copy semantics, so the 
message is a copy, so the receiving thread gets a copy, not a reference.

Immutables can be passed by reference, because immutables have value 
semantics.

Mutable objects are reference types, and so cannot be passed as messages.


More information about the dmd-concurrency mailing list