remove sleep calls from Runnable

This commit is contained in:
Alex Fabijanic 2014-04-26 16:04:17 -05:00
parent 63850e8778
commit 695ba1b0ee
5 changed files with 8 additions and 22 deletions

View File

@ -58,11 +58,6 @@ public:
virtual void run() = 0;
/// Do whatever the thread needs to do. Must
/// be overridden by subclasses.
protected:
void sleep(long milliseconds);
bool trySleep(long milliseconds);
};

View File

@ -187,7 +187,7 @@ public:
bool isRunning() const;
/// Returns true if the thread is running.
bool trySleep(long milliseconds);
static bool trySleep(long milliseconds);
/// Starts an interruptible sleep. When trySleep() is called,
/// the thread will remain suspended until:
/// - the timeout expires or

View File

@ -51,16 +51,4 @@ Runnable::~Runnable()
}
void Runnable::sleep(long milliseconds)
{
Thread::sleep(milliseconds);
}
bool Runnable::trySleep(long milliseconds)
{
return Thread::current()->trySleep(milliseconds);
}
} // namespace Poco

View File

@ -126,9 +126,12 @@ bool Thread::tryJoin(long milliseconds)
bool Thread::trySleep(long milliseconds)
{
return !_event.tryWait(milliseconds);
Thread* pT = Thread::current();
poco_check_ptr(pT);
return !(pT->_event.tryWait(milliseconds));
}
void Thread::wakeUp()
{
_event.set();

View File

@ -143,11 +143,11 @@ public:
void run()
{
_sleepy = !trySleep(300000);
_sleepy = !Thread::trySleep(300000);
++_counter;
_sleepy = !trySleep(300000);
_sleepy = !Thread::trySleep(300000);
++_counter;
_sleepy = !trySleep(10);
_sleepy = !Thread::trySleep(10);
++_counter;
}