Changeset 425 for experimental/Threading/Threading/SimHost.cpp
- Timestamp:
- Oct 21, 2012, 12:05:47 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/Threading/Threading/SimHost.cpp
r421 r425 33 33 OpenThreads::Barrier syncBarrier; 34 34 35 // Create ChannelWorkers36 OSG_ALWAYS<<"Creating ChannelWorkers..."<<std::endl;35 // Create IG Connectors 36 OSG_ALWAYS<<"Creating IG Connectors..."<<std::endl; 37 37 for(int i=0; i<numThreads-1; ++i) 38 38 { 39 osg::ref_ptr<ChannelWorker> worker = new ChannelWorker(); 40 _channelWorker.push_back(worker); 39 osg::ref_ptr<ThreadedWorker> threadObject = new ThreadedWorker(); 40 osg::ref_ptr<IGConnector> IGCon = new IGConnector(); 41 threadObject->setThreadWorker(IGCon); 42 _threadObjects.push_back(threadObject); 43 _IGConnectors.push_back(IGCon); 41 44 } 42 45 OSG_ALWAYS<<"...done."<<std::endl; … … 55 58 { 56 59 // Launch threads 57 for(int i=0;i<static_cast<int>(_ channelWorker.size());++i)60 for(int i=0;i<static_cast<int>(_threadObjects.size());++i) 58 61 { 59 62 int status; 60 63 61 64 //thread->setStackSize(1024*256); 62 status = _ channelWorker[i]->start();65 status = _threadObjects[i]->start(); 63 66 assert(status == 0); 64 67 } 65 68 66 69 // Do something in the main thread 67 for(int i=0;i<10000000;i++) 68 OSG_ALWAYS<<""; 70 for(int i=0;i<10000000;i++) OSG_ALWAYS<<""; 69 71 70 72 // Signal threads to finish 71 for(int i=0;i<static_cast<int>(_ channelWorker.size());++i)73 for(int i=0;i<static_cast<int>(_threadObjects.size());++i) 72 74 { 73 //_ channelWorker[i]->setDone(true); // non blocking74 _ channelWorker[i]->cancel(); // Blocking75 //_threadObjects[i]->setDone(true); // non blocking 76 _threadObjects[i]->cancel(); // Blocking 75 77 } 76 78 … … 78 80 OSG_ALWAYS<<""; 79 81 80 //syncBarrier.block(numThreads); // Block until all threads are ready81 82 }
Note: See TracChangeset
for help on using the changeset viewer.