Sharing in D

Walter Bright newshound1 at digitalmars.com
Thu Jul 31 22:12:18 PDT 2008


Sean Kelly wrote:
> Sounds like the addition of a thread-local storage class (which
> I've been asking for since I discovered D),

It's actually implemented in D 2.0 as the __thread storage class, 
however it's for testing purposes only.

> plus some language
> checking on top of that.  I'll admit to being somewhat concerned
> that the checking aspect will incur an unwanted runtime expense,
> as I don't believe there's any way at compile-time to detect that
> a variable is being accessed by multiple threads.

It's done statically by the type - a shared type can be accessed by 
multiple types, an unshared type cannot.

> It's too bad we've been unable to talk about any of this
> offline.  We've been considering doing a lot of this sort
> of thing with Tango for years now but had been avoiding any
> unnecessary runtime changes in hopes that it would increase
> the likelihood that the powers that be would get involved.
> Obviously, that idea failed :-)  But I'll take this as
> implicit permission to have at it, since you seem to be
> talking along roughly similar lines for D2 anyway.

We've been talking about doing it as a static type system, not as a 
runtime one. Bartosz mentioned that there are ways to do it at runtime, 
but there are a lot of issues that would need to be worked out for that.



More information about the Digitalmars-d mailing list