Skip to content
Snippets Groups Projects
Commit 945eec50 authored by Philippe Gorley's avatar Philippe Gorley Committed by Philippe Gorley
Browse files

thread: add blocking join

Adds a way to wait until the thread finishes its work before joining.

Change-Id: I7080a4515ce6c1158c74c6eb8973a13a4b097419
parent b59f5cb6
Branches
No related tags found
No related merge requests found
...@@ -110,7 +110,15 @@ ThreadLoop::join() ...@@ -110,7 +110,15 @@ ThreadLoop::join()
thread_.join(); thread_.join();
} }
void ThreadLoop::exit() void
ThreadLoop::waitForCompletion()
{
if (thread_.joinable())
thread_.join();
}
void
ThreadLoop::exit()
{ {
stop(); stop();
throw ThreadLoopException(); throw ThreadLoopException();
......
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
void exit(); void exit();
virtual void stop(); virtual void stop();
void join(); void join();
void waitForCompletion(); // thread will stop itself
bool isRunning() const noexcept; bool isRunning() const noexcept;
bool isStopping() const noexcept; bool isStopping() const noexcept;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment