digitalmars.D - Getting All Instances of a Thread-Local
- dsimcha (8/8) Jan 16 2009 Using D2's builtin thread-local storage, is there a way to get all insta...
- Sergey Gromov (4/13) Jan 17 2009 I wonder if struct destructor is called if you put it in TLS and thread
- dsimcha (2/15) Jan 17 2009 No, it isn't. Just tried it.
- Sergey Gromov (5/21) Jan 18 2009 OTOH, if you can gain access to the data, it's not thread-local anymore.
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.
Jan 16 2009
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'.
Jan 17 2009
== Quote from Sergey Gromov (snake.scaly gmail.com)'s articleSat, 17 Jan 2009 05:17:29 +0000 (UTC), dsimcha wrote:No, it isn't. Just tried it.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'.
Jan 17 2009
Sat, 17 Jan 2009 16:02:12 +0000 (UTC), dsimcha wrote:== Quote from Sergey Gromov (snake.scaly gmail.com)'s articleOTOH, if you can gain access to the data, it's not thread-local anymore. Simply put your data synchronously into a global array when it's ready, and synchronously remove it when a thread dies. You can use scope() or RAII in your thread function for that.Sat, 17 Jan 2009 05:17:29 +0000 (UTC), dsimcha wrote:No, it isn't. Just tried it.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'.
Jan 18 2009