On Friday 26 January 2007 21:30, Frederic Bouvier wrote: > Update of /var/cvs/SimGear-0.3/SimGear/simgear/scene/model > In directory baron:/tmp/cvs-serv5514 > > Modified Files: > shadanim.cxx > Log Message: > Ensure a reference on the cube map texture is always held
Fred, that code was correct (appart from not being deleted). I have that kind of code at more places. That technique called 'double checked locking'. You don't bother locking a mutex if it is already there. But if the instance must be created, you have to ensure that you are the only one. therefore you need to ask if it is there a second time ... That is not time critical here, so I don't bother locking, but in general this kind of code should be left as is ... Greetings Mathias > > Index: shadanim.cxx > =================================================================== > RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/scene/model/shadanim.cxx,v > retrieving revision 1.9 > retrieving revision 1.10 > diff -C 2 -r1.9 -r1.10 > *** shadanim.cxx 3 Dec 2006 16:57:21 -0000 1.9 > --- shadanim.cxx 26 Jan 2007 20:30:02 -0000 1.10 > *************** > *** 127,138 **** > getOrCreateTextureCubeMap() > { > ! static osg::TextureCubeMap* textureCubeMap = 0; > ! if (textureCubeMap) > ! return textureCubeMap; > > static SGMutex mutex; > SGGuard<SGMutex> locker(mutex); > ! if (textureCubeMap) > ! return textureCubeMap; > > // create and setup the texture object > --- 127,136 ---- > getOrCreateTextureCubeMap() > { > ! static osg::ref_ptr<osg::TextureCubeMap> textureCubeMap; > > static SGMutex mutex; > SGGuard<SGMutex> locker(mutex); > ! if (textureCubeMap.get()) > ! return textureCubeMap.get(); > > // create and setup the texture object > *************** > *** 147,151 **** > textureCubeMap->setUpdateCallback(new SGMapGenCallback); > > ! return textureCubeMap; > } > > --- 145,149 ---- > textureCubeMap->setUpdateCallback(new SGMapGenCallback); > > ! return textureCubeMap.get(); > } > > > > _______________________________________________ > Simgear-cvslogs mailing list > [EMAIL PROTECTED] > http://mail.flightgear.org/mailman/listinfo/simgear-cvslogs > 2f585eeea02e2c79d7b1d8c4963bae2d ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel