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

Legend:

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

    r424 r425  
    11#include "ThreadedWorker.h"
    22#include <osg/Notify>
     3#include <OpenThreads/ScopedLock>
    34
    45
     
    1920
    2021        // Do the work
    21         int i=0;
    2222        do
    2323        {
    24                 OSG_ALWAYS<<"ID "<<getThreadId()<<" :: itr "<<i++<<std::endl;
     24                OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_threadWorkerMutex);
    2525
    26                 // Place Holder
    27                 for(int i=0;i<100;i++)
    28                 OSG_ALWAYS<<"";
    29 
    30         } while (!testCancel() && !_done);      // repeat as long it is canceld or set as Done
     26                if( _threadWorker.valid() )
     27                        (*_threadWorker)(this);
     28               
     29        } while (_threadWorker!=NULL && !testCancel() && !_done);       // repeat as long as a functor is set and it is not canceled or set as Done
    3130}
    3231
     
    6059    return 0;
    6160}
     61
     62void ThreadedWorker::setThreadWorker( ThreadWorkerBase* tworker)
     63{
     64        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_threadWorkerMutex);
     65
     66        _threadWorker = tworker;
     67}
Note: See TracChangeset for help on using the changeset viewer.