Rev | Line | |
---|
[420] | 1 | #pragma once |
---|
| 2 | |
---|
| 3 | #include <osg/Referenced> |
---|
| 4 | #include <OpenThreads/Thread> |
---|
| 5 | |
---|
[422] | 6 | /** |
---|
| 7 | * \brief This class is a Thread Object which allows to create Functors and attach them to this thread object. |
---|
| 8 | * |
---|
| 9 | * @author Torben Dannhauer |
---|
| 10 | * @date Okt 2012 |
---|
| 11 | */ |
---|
[423] | 12 | class ThreadedWorker : public osg::Referenced, public OpenThreads::Thread |
---|
[420] | 13 | { |
---|
| 14 | public: |
---|
[423] | 15 | ThreadedWorker() ; |
---|
| 16 | ~ThreadedWorker(); //Destroying the thread object will implicit call cancel(), then the function will block until the thread has finished. |
---|
[420] | 17 | virtual void run(); |
---|
| 18 | virtual int cancel(); |
---|
| 19 | |
---|
[421] | 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. |
---|
| 21 | bool getDone() const { return _done; } |
---|
[420] | 22 | |
---|
| 23 | private: |
---|
| 24 | bool _done; |
---|
| 25 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.