- Timestamp:
- 01/25/08 14:32:12 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Carsten_PtrWork2/Source/System/NodeCores/Groups/Misc/testSimpleMT.cpp
r1041 r1042 17 17 Barrier *gSyncBarrier; 18 18 19 volatile bool exitFlag = false;19 volatile bool gExitFlag = false; 20 20 21 21 class TreePrinter … … 103 103 // +- n2N 104 104 105 bool exitFlag = false; 106 105 107 NodeRefPtr n0N = makeCoredNode<Group>(); 106 108 NodeRefPtr n1N = makeCoredNode<Group>(); … … 141 143 SLOG << " === threadFunc0: modify loop start [" << loopCount << "]" << endLog; 142 144 143 SLOG << "threadFunc0: modify loop [" << loopCount << "]: pre barrier 1" << endLog;144 145 gSyncBarrier->enter(2); 145 146 146 147 // wait for other threads to sync their aspects 147 148 148 SLOG << "threadFunc0: modify loop [" << loopCount << "]: pre barrier 2" << endLog; 149 gSyncBarrier->enter(2); 150 151 SLOG << "threadFunc0: modify loop [" << loopCount << "]: 'modify' scene" << endLog; 152 149 if(gExitFlag == true) 150 exitFlag = true; // set the local exit flag 151 152 gSyncBarrier->enter(2); 153 154 if(exitFlag == true) 155 break; 156 153 157 Thread::getCurrentChangeList()->clear(); 154 158 … … 158 162 case 0: 159 163 { 160 SLOG << "threadFunc0 modify loop [" << loopCount << "]: changing trans" << endLog;161 162 164 trans->editMatrix().setTranslate( 163 165 Vec3f(osgRand(), osgRand(), osgRand())); … … 168 170 case 1: 169 171 { 170 SLOG << "threadFunc0 modify loop [" << loopCount << "]: child transN -> groupN" << endLog;171 172 172 NodeRefPtr moveChild; 173 173 … … 182 182 case 2: 183 183 { 184 SLOG << "threadFunc0 modify loop [" << loopCount << "]: child groupN -> transN" << endLog;185 186 184 NodeRefPtr moveChild; 187 185 … … 197 195 commitChanges(); 198 196 } 199 while( !exitFlag); // only this thread detects exit requests197 while(true); 200 198 201 199 SLOG << "threadFunc0: STOP" << endLog; … … 206 204 TreePrinter tp(std::cerr); 207 205 206 bool exitFlag = false; 207 208 208 SLOG << "threadFunc1: START" << endLog; 209 209 … … 216 216 SLOG << " === threadFunc1: render loop start [" << loopCount << "]" << endLog; 217 217 218 SLOG << "threadFunc1: render loop [" << loopCount << "]: pre barrier 1" << endLog; 219 gSyncBarrier->enter(2); 220 221 SLOG << "threadFunc1: render loop [" << loopCount << "]: pre SYNC scene" << endLog; 218 gSyncBarrier->enter(2); 219 222 220 223 221 gThread0->getChangeList()->applyNoClear(); 224 222 225 SLOG << "threadFunc1: render loop [" << loopCount << "]: post SYNC scene" << endLog; 226 227 SLOG << "threadFunc1: render loop [" << loopCount << "]: pre barrier 2" << endLog; 228 gSyncBarrier->enter(2); 229 230 SLOG << "threadFunc1: render loop [" << loopCount << "]: 'render' scene" << endLog; 223 if(gExitFlag == true) 224 exitFlag = true; // set the local exit flag 225 226 gSyncBarrier->enter(2); 227 228 if(exitFlag == true) 229 break; 231 230 232 231 traverse(gRootN, boost::bind(&TreePrinter::enterFunc, &tp, _1 ), … … 235 234 ++loopCount; 236 235 } 237 while(true); // this thread runs forever236 while(true); 238 237 239 238 SLOG << "threadFunc1: STOP" << endLog; … … 254 253 osgSleep(1000); 255 254 256 exitFlag = true; // signal thread0to exit257 Thread::join(gThread0); // wait for thread0258 259 gThread1->terminate(); // signal thread1 to exit255 gExitFlag = true; // signal threads to exit 256 257 Thread::join(gThread0); // wait for threads 258 Thread::join(gThread1); 260 259 261 260 osgExit();
