Ignore:
Timestamp:
Oct 25, 2012, 9:49:08 AM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/Threading/Threading/SimHost.cpp

    r426 r430  
    33
    44#include <OpenThreads/Thread>
    5 #include <OpenThreads/Barrier>
    65
    76// System includes
     
    2120{
    2221        OSG_ALWAYS<<"SimHost instantiated."<<std::endl;
     22        numberofChannels = 6;
    2323}
    2424
     
    3030void SimHost::initialize()
    3131{
    32         int numThreads = 6+1;   // 6 channels and one main thread
     32        done = false;
     33        int numThreads = numberofChannels+1;    // #channels + one main thread
    3334        OpenThreads::Barrier syncBarrier;
    3435
    3536        // Create IG Connectors
    3637        OSG_ALWAYS<<"Creating IG Connectors..."<<std::endl;
    37         for(int i=0; i<numThreads-1; ++i)
     38        for(int i=0; i<numberofChannels; ++i)
    3839        {
    3940                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);
    4142                threadObject->setThreadWorker(IGCon);
    4243                _threadObjects.push_back(threadObject);
     
    6768        }
    6869
    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        }
    7177       
    7278        // Signal threads to finish
     
    7682                _threadObjects[i]->cancel();    // Blocking
    7783        }
    78 
    79         /*for(int i=0;i<100000000;i++)
    80                 OSG_ALWAYS<<"";*/
    81 
    8284}
Note: See TracChangeset for help on using the changeset viewer.