From a1ec4232353d56d4c7ffbec01bde7ce88234cf80 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 30 Sep 2013 09:28:31 -0700 Subject: [PATCH] Add Thread::stopThreadAsync --- modules/beast_core/threads/Thread.cpp | 11 +++++++++++ modules/beast_core/threads/Thread.h | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/modules/beast_core/threads/Thread.cpp b/modules/beast_core/threads/Thread.cpp index d9d5a7ab3..6a573dd66 100644 --- a/modules/beast_core/threads/Thread.cpp +++ b/modules/beast_core/threads/Thread.cpp @@ -208,6 +208,17 @@ bool Thread::stopThread (const int timeOutMilliseconds) return cleanExit; } +void Thread::stopThreadAsync () +{ + const ScopedLock sl (startStopLock); + + if (isThreadRunning()) + { + signalThreadShouldExit(); + notify(); + } +} + //============================================================================== bool Thread::setPriority (const int newPriority) { diff --git a/modules/beast_core/threads/Thread.h b/modules/beast_core/threads/Thread.h index 8aa85024c..8cf8cf151 100644 --- a/modules/beast_core/threads/Thread.h +++ b/modules/beast_core/threads/Thread.h @@ -110,6 +110,11 @@ public: */ bool stopThread (int timeOutMilliseconds = -1); + /** Stop the thread without blocking. + This calls signalThreadShouldExit followed by notify. + */ + void stopThreadAsync (); + //============================================================================== /** Returns true if the thread is currently active */ bool isThreadRunning() const;