The "no gc" crowd

Jacob Carlborg doob at me.com
Fri Oct 11 02:50:47 PDT 2013


On 2013-10-11 03:05, Jonathan M Davis wrote:

> I'm not disagreeing with how shared works. I'm disagreeing with the idea that
> it's not supposed to be normal to cast shared away when operating on shared
> objects. I expect that the most common idiom for dealing with shared is to
> protect it with a lock, cast it to thread-local, do whatever you're going to
> do with it, make sure that there are no thread-local references to it once
> you're done operating on it, and then release the lock. e.g.
>
> synchronized
> {
>   auto tc = cast(T)mySharedT;
>   tc.memberFunc();
>   doStuff(tc);
>   //no thread-local references to tc other than tc should
>   //exist at this point.
> }

With Michel Fortin's proposal I think the above could work without a 
cast, if doStuff is pure function.

http://michelf.ca/blog/2012/mutex-synchonization-in-d/

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list