[dmd-concurrency] is shared going to be a type modifier?

Sean Kelly sean at invisibleduck.org
Thu Jan 7 15:07:39 PST 2010


On Jan 7, 2010, at 2:10 PM, Steve Schveighoffer wrote:

> ----- Original Message ----
> 
>> From: Michel Fortin <michel.fortin at michelf.com>
>> Le 2010-01-07 à 15:34, Steve Schveighoffer a écrit :
>> 
>>> In fact, any shared class reference on the stack erroneously will create 
>> memory barriers around the stack variable itself -- you shouldn't be sharing any 
>> stack data.
>> 
>> I'm not sure you should never be sharing stack data. Stack data can already be 
>> allocated on the heap with closures. If you're going to give that closure to 
>> another thread, the data it uses needs to be shared.
> 
> If you pass a closure to another thread, the whole stack frame should be marked as shared because you are passing the whole stack frame.

While some people may want to cowboy and send a "scope delegate" to another thread, I can assure you this won't be possible in any Phobos messaging API.  It's too much of a recipe for disaster.  Following the per-thread GC model I can see even accepting a "shared delegate" to indicate that it will be passed to another thread.


More information about the dmd-concurrency mailing list