Commit 2729e7f7 authored by ledig's avatar ledig
Browse files

[REMOVE] removed OpenThread dependency of WThreadedRunner though it doesn't...

[REMOVE] removed OpenThread dependency of WThreadedRunner though it doesn't compile anymore in win and the error it fixed doesn't occure since the usage of WGEGroupNode
parent 2246946d
......@@ -30,17 +30,11 @@
#include "WThreadedRunner.h"
WThreadedRunner::WThreadedRunner():
#if !USE_BOOST_THREADS
OpenThreads::Thread(),
#endif
m_shutdownFlag( new WConditionOneShot, false )
{
// initialize members
m_FinishRequested = false;
m_Thread = NULL;
#if !USE_BOOST_THREADS
m_firstRun = true;
#endif
}
WThreadedRunner::~WThreadedRunner()
......@@ -48,44 +42,20 @@ WThreadedRunner::~WThreadedRunner()
// cleanup
// XXX is this working if thread already has finished?
// wait( true ); <-- no
#if USE_BOOST_THREADS
if( m_Thread )
{
delete m_Thread;
}
#endif
}
void WThreadedRunner::run()
{
#if USE_BOOST_THREADS
m_Thread = new boost::thread( boost::bind( &WThreadedRunner::threadMain, this ) );
#else
if ( m_firstRun )
{
m_firstRun = false;
m_Thread = this;
Init();
start();
}
else
{
threadMain();
}
#endif
}
void WThreadedRunner::run( THREADFUNCTION f )
{
#if USE_BOOST_THREADS
m_Thread = new boost::thread( f );
#else
m_firstRun = false;
m_Thread = this;
Init();
start();
f();
#endif
}
void WThreadedRunner::wait( bool requestFinish )
......@@ -118,28 +88,16 @@ void WThreadedRunner::notifyStop()
void WThreadedRunner::yield() const
{
#if USE_BOOST_THREADS
m_Thread->yield();
#else
m_Thread->YieldCurrentThread();
#endif
}
void WThreadedRunner::sleep( const int32_t t ) const
{
#if USE_BOOST_THREADS
boost::this_thread::sleep( boost::posix_time::seconds( t ) );
#else
m_Thread->microSleep( 1000000 * t );
#endif
}
void WThreadedRunner::msleep( const int32_t t ) const
{
#if USE_BOOST_THREADS
boost::this_thread::sleep( boost::posix_time::microseconds( t ) );
#else
m_Thread->microSleep( t );
#endif
}
......@@ -27,22 +27,10 @@
#include <stdint.h>
#ifdef _MSC_VER
#define USE_BOOST_THREADS 0
#else
#define USE_BOOST_THREADS 1
#endif
#if !USE_BOOST_THREADS
#include <OpenThreads/Thread>
#endif
#include <boost/function.hpp>
#if USE_BOOST_THREADS
#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
#endif
#include "WFlag.h"
......@@ -50,9 +38,6 @@
* Base class for all classes needing to be executed in a separate thread.
*/
class WThreadedRunner
#if !USE_BOOST_THREADS
: public OpenThreads::Thread
#endif
{
public:
......@@ -106,13 +91,7 @@ protected:
/**
* Thread instance.
*/
#if USE_BOOST_THREADS
boost::thread* m_Thread;
#else
OpenThreads::Thread *m_Thread;
bool m_firstRun;
#endif
/**
* True if thread should end execution. NOTE: do not use this. Use m_shutdownFlag instead.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment