Getting All Instances of a Thread-Local

dsimcha dsimcha at yahoo.com
Sat Jan 17 08:02:12 PST 2009


== Quote from Sergey Gromov (snake.scaly at gmail.com)'s article
> Sat, 17 Jan 2009 05:17:29 +0000 (UTC), dsimcha wrote:
> > Using D2's builtin thread-local storage, is there a way to get all instances
> > (one per thread) of a given thread-local variable?  If not, can anyone
> > recommend any workarounds, given that:
> >
> > 1.  Each instance of this variable is not written to after initialization,
> > i.e. not more than once during the execution of the program.
> > 2.  I must be able to tell instances created by threads that are still alive
> > from those created by dead threads.  This rules out simply appending the
> > values to an array.
> I wonder if struct destructor is called if you put it in TLS and thread
> dies.  Then you could use RAII to remove irrelevant data from the
> 'simple array'.

No, it isn't.  Just tried it.



More information about the Digitalmars-d mailing list