Re: handling static variables in parallel code



On 10 août, 17:11, Naveen Parihar <naveenpari...@xxxxxxxxx> wrote:
On Aug 10, 1:22 am, Steve Watt <steve.removet...@xxxxxxxx> wrote:



% 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.
It can be if you scope the key (which you can do with a static).

rlc

.



Relevant Pages

  • Re: Many global vars in an A97 app - good or bad? Why?
    ... especially the past about appropriate scope. ... >Passing data between forms: why do so few people know about the ... >>Global variables are decidely poorly suited to these two purposes, ... This could be a global class module variable, ...
    (comp.databases.ms-access)
  • Re: How to eliminate this global variable, silent?
    ... Excluding it because it doesn't have global scope is perfectly correct. ... The only argument you can present is: the standard doesn't ... define "global variables". ... yadda yadda. ...
    (comp.lang.c)
  • Re: Trouble with variable scoping
    ... You are confusing file scope with global. ... That is possibly the most common misperception about Perl that I've ... fully-qualify any global variables you decide to use. ... a lexical variable $foo exists in the current scope. ...
    (perl.beginners)
  • Re: VB 6.0 Desktop - Global Variables
    ... MikeD schrieb: ... As has been stated, global variables tend to make maintainability much more difficult and, IMO, make bugs much more likely. ... As you say, having project wide scope, but also without needing a reference to an object. ...
    (microsoft.public.vb.general.discussion)
  • Re: for x in... x remains global
    ... Antoine De Groote wrote: ... in a separate scope, but variables are never local to a block. ...
    (comp.lang.python)