Thread-local Member Variables?

Jason House jason.james.house at gmail.com
Wed Jan 13 06:26:03 PST 2010


dsimcha Wrote:

> Should there be a way, in D, to create a variable that's local to both a
> thread and a class instance?  For example:
> 
> class Foo {
>     __thread uint num;
> }
> 
> num would basically be a reference to thread-local storage, with a new one
> created for every instance of Foo.  Is there a (non-hacky) way to do this already?

D1 or D2? For D2, this would only matter for shared and __gshared variables. For shared variables, it makes about as much sense as logical const. I'm going to guess that logical shared won't make it into D2. I have no idea about __gshared, but I'm going to guess that functionality won't grow beyond its current state. For some reason, I think D had __thread at one time...



More information about the Digitalmars-d mailing list