Ignore:
Timestamp:
Oct 21, 2012, 12:05:47 AM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

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

    r421 r425  
    3333        OpenThreads::Barrier syncBarrier;
    3434
    35         // Create ChannelWorkers
    36         OSG_ALWAYS<<"Creating ChannelWorkers..."<<std::endl;
     35        // Create IG Connectors
     36        OSG_ALWAYS<<"Creating IG Connectors..."<<std::endl;
    3737        for(int i=0; i<numThreads-1; ++i)
    3838        {
    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);
    4144        }
    4245        OSG_ALWAYS<<"...done."<<std::endl;
     
    5558{
    5659        // 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)
    5861        {
    5962                int status;
    6063               
    6164                //thread->setStackSize(1024*256);
    62                 status = _channelWorker[i]->start();
     65                status = _threadObjects[i]->start();
    6366                assert(status == 0);
    6467        }
    6568
    6669        // 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<<"";
    6971       
    7072        // 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)
    7274        {
    73                 //_channelWorker[i]->setDone(true);     // non blocking
    74                 _channelWorker[i]->cancel();    // Blocking
     75                //_threadObjects[i]->setDone(true);     // non blocking
     76                _threadObjects[i]->cancel();    // Blocking
    7577        }
    7678
     
    7880                OSG_ALWAYS<<"";
    7981
    80         //syncBarrier.block(numThreads);  // Block until all threads are ready
    8182}
Note: See TracChangeset for help on using the changeset viewer.