Re: handling static variables in parallel code
- From: blytkerchan <blytkerchan@xxxxxxxxx>
- Date: Sat, 25 Aug 2007 18:29:18 -0700
On 10 août, 17:11, Naveen Parihar <naveenpari...@xxxxxxxxx> wrote:
On Aug 10, 1:22 am, Steve Watt <steve.removet...@xxxxxxxx> wrote:It can be if you scope the key (which you can do with a static).
% man pthread_key_create
You're reinventing thread-specific data. It even comes with destructors.
...
The problem with thread-specific data is that it gives a back-door path
for bugs, just the same as global variables can. If the data is really
related to one instance of an object, and somehow the thread gets passed
another instance of the object and calls a method, you've now got ugly
dependencies that will bite you.
Thanks to everyone who replied. Thread-specific data is what I was
looking for. Wish the scope of thread-specific data was limited
similar to the scope of static variables.
rlc
.
- References:
- handling static variables in parallel code
- From: Naveen Parihar
- Re: handling static variables in parallel code
- From: Steve Watt
- Re: handling static variables in parallel code
- From: Naveen Parihar
- handling static variables in parallel code
- Prev by Date: Re: thread synchronization of flag
- Next by Date: Re: thread synchronization of flag
- Previous by thread: Re: handling static variables in parallel code
- Next by thread: Re: Multi Threading and portability issues
- Index(es):
Relevant Pages
|