The "no gc" crowd

Jacob Carlborg doob at me.com
Wed Oct 9 23:38:31 PDT 2013


On 2013-10-10 05:55, Jonathan M Davis wrote:

> That depends. It works with objects I think (for both shared and immutable),
> but you definitely have to cast to immutable if you want an immutable array or
> AA.
>
> Also, casting _away_ shared is going to be a very common operation due to how
> shared works. In order to use shared, you basically have to protect the
> variable with a mutex or synchronized block, cast away shared, and then use it
> as thread-local for whatever you're doing until you release the lock (in which
> case, you have to be sure that there are no more thread-local references to
> the shared object). As such, while it might be possible to construct stuff
> directly as shared, it's going to have to be cast to thread-local just to use
> it in any meaningful way. So, at this point, I don't think that it even
> vaguely flies to try and make it so that casting away shared is something that
> isn't typically done. It's going to be done about as often as shared is used
> for anything other than very basic stuff.

What's the reason for casting away "shared", is it to pass it to a 
function that doesn't accept "shared"? The it should be safe if you 
synchronize around the call? But that function could put away, the now , 
unshared data, which is actually shared and cause problem?


-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list