Changes in src/World.cpp [a77c96:23b547]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/World.cpp
ra77c96 r23b547 16 16 #include "Descriptors/MoleculeDescriptor_impl.hpp" 17 17 #include "Actions/ManipulateAtomsProcess.hpp" 18 19 #include "Patterns/Singleton_impl.hpp" 18 20 19 21 using namespace std; … … 229 231 /******************************* Singleton Stuff **************************/ 230 232 231 // TODO: Hide boost-thread using Autotools stuff when no threads are used232 World* World::theWorld = 0;233 boost::mutex World::worldLock;234 235 233 World::World() : 236 234 periode(new periodentafel), … … 261 259 } 262 260 263 World* World::get(){ 264 // boost supports RAII-Style locking, so we don't need to unlock 265 boost::mutex::scoped_lock guard(worldLock); 266 if(!theWorld) { 267 theWorld = new World(); 268 } 269 return theWorld; 270 } 271 272 void World::destroy(){ 273 // boost supports RAII-Style locking, so we don't need to unlock 274 boost::mutex::scoped_lock guard(worldLock); 275 delete theWorld; 276 theWorld = 0; 277 } 278 279 World* World::reset(){ 280 World* oldWorld = 0; 281 { 282 // boost supports RAII-Style locking, so we don't need to unlock 283 boost::mutex::scoped_lock guard(worldLock); 284 285 oldWorld = theWorld; 286 theWorld = new World(); 287 // oldworld does not need protection any more, 288 // since we should have the only reference 289 290 // worldLock handles access to the pointer, 291 // not to the object 292 } // scope-end releases the lock 293 294 // we have to let all the observers know that the 295 // oldWorld was destroyed. oldWorld calls subjectKilled 296 // upon destruction. Every Observer getting that signal 297 // should see that it gets the updated new world 298 delete oldWorld; 299 return theWorld; 300 } 261 // Explicit instantiation of the singleton mechanism at this point 262 263 CONSTRUCT_SINGLETON(World) 301 264 302 265 /******************************* deprecated Legacy Stuff ***********************/
Note:
See TracChangeset
for help on using the changeset viewer.