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/ThreadedWorker.h

    r424 r425  
    22
    33#include <osg/Referenced>
     4#include <osg/ref_ptr>
    45#include <OpenThreads/Thread>
     6#include <OpenThreads/Mutex>
     7
     8#include "ThreadWorkerBase.h"
     9
    510
    611/**
    712 * \brief This class is a Thread Object which allows to create Functors and attach them to this thread object.
     13 *
     14 * Subclass ThreadWorkerBase to implement your own functor to execute your custom code threaded.
     15 *
     16 * Use setDone(true) to shut down the thread nonblocking, or call cancel() to shut down the thread blocking (both called from outside of the workerthread).
     17 * Inside the workerthread's functor, you can set the functor parameter done=true to shutdown the thread after the current execution.
     18 *
    819 *
    920 * @author Torben Dannhauer
     
    1829        virtual int cancel();
    1930       
    20         void setDone(bool done);        // sinbgals the thread to stop but returns immediately. Use cancel if you want to wait blocking until the thread is canceled.
     31        void setDone(bool done);        // signals the thread to stop but returns immediately. Use cancel if you want to wait blocking until the thread is canceled.
    2132        bool getDone() const { return _done; } 
     33
     34        void setThreadWorker( ThreadWorkerBase* tworker);       // This function sets the functor which should be executed threaded. Set NULL to remove the current functor and cancel the thread.
     35        ThreadWorkerBase* getCurrentThreadWorker()              {return(_threadWorker);};
    2236
    2337private:
    2438        bool _done;
     39        osg::ref_ptr<ThreadWorkerBase> _threadWorker;
     40        OpenThreads::Mutex _threadWorkerMutex;  // Ensures the functor is not replacable while it is executed
    2541};
Note: See TracChangeset for help on using the changeset viewer.