Thread-local Member Variables?

Nick Sabalausky a at a.a
Wed Jan 13 13:28:39 PST 2010


"dsimcha" <dsimcha at yahoo.com> wrote in message 
news:hikj7a$18lq$1 at digitalmars.com...
> 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?

How would that be different from doing this in D2?:

class Foo {
   uint num;
}

'num' isn't declared as static, so a new one is created for every instance 
of Foo, and 'shared' isn't used so it's thread local. Am I missing 
something? 





More information about the Digitalmars-d mailing list