Changeset 430 for experimental/Threading/Threading/SimHost.cpp
- Timestamp:
- Oct 25, 2012, 9:49:08 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/Threading/Threading/SimHost.cpp
r426 r430 3 3 4 4 #include <OpenThreads/Thread> 5 #include <OpenThreads/Barrier>6 5 7 6 // System includes … … 21 20 { 22 21 OSG_ALWAYS<<"SimHost instantiated."<<std::endl; 22 numberofChannels = 6; 23 23 } 24 24 … … 30 30 void SimHost::initialize() 31 31 { 32 int numThreads = 6+1; // 6 channels and one main thread 32 done = false; 33 int numThreads = numberofChannels+1; // #channels + one main thread 33 34 OpenThreads::Barrier syncBarrier; 34 35 35 36 // Create IG Connectors 36 37 OSG_ALWAYS<<"Creating IG Connectors..."<<std::endl; 37 for(int i=0; i<num Threads-1; ++i)38 for(int i=0; i<numberofChannels; ++i) 38 39 { 39 40 osg::ref_ptr<ThreadedWorker> threadObject = new ThreadedWorker(); 40 osg::ref_ptr<IGConnector> IGCon = new IGConnector( );41 osg::ref_ptr<IGConnector> IGCon = new IGConnector(numberofChannels, _frameBarrier); 41 42 threadObject->setThreadWorker(IGCon); 42 43 _threadObjects.push_back(threadObject); … … 67 68 } 68 69 69 // Do something in the main thread 70 for(int i=0;i<10000000;i++) OSG_ALWAYS<<""; 70 // Enter the SimHost main loop 71 while(!done) 72 { 73 // Wait until all Channels have sent an SOF packet 74 _frameBarrier.block(numberofChannels+1); // Sync the main and all IG threads. 75 OSG_ALWAYS<<"All IGConnectors have recieved a SOF packet: Starting new Frame"<<std::endl; 76 } 71 77 72 78 // Signal threads to finish … … 76 82 _threadObjects[i]->cancel(); // Blocking 77 83 } 78 79 /*for(int i=0;i<100000000;i++)80 OSG_ALWAYS<<"";*/81 82 84 }
Note: See TracChangeset
for help on using the changeset viewer.