Le vendredi 02 mai 2008 à 10:34 +0200, Tim Moore a écrit :
> This concern is valid, but *every* use of SGMutex removed in Benôit's patch is
> not actually thread safe now! Static local variables are initialized the first
> time a function is called. I'm not sure if the proper lesson to take away is
> that threading is hard, because of subtle issues like this, or if it's easy,
> because it works even in the presence of such bugs ;)

I looked at the code again and, if I understand your warning, there is 2
options:

1/ I'm completely dumb (which is possible ;))
2/ The old code was not thread safe either.

Old code
static SGMutex mutex;
------

New code
static OpenThreads::Mutex mutex;
------

As a side note, it seems you already use OpenThreads Mutexes in various
places, like in line 939 of simgear/scene/model/animation.cxx:

OpenThreads::ScopedLock<OpenThreads::Mutex> lock(normalizeMutex);

or in line 72 of simgear/scene/util/StateAttributeFactory.cxx:

OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_instanceMutex);

Would this produce the correct behavior ?

Regards,
Benoît


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to