aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CommonLibs/Threads.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/CommonLibs/Threads.h b/CommonLibs/Threads.h
index a38a73a..47c7275 100644
--- a/CommonLibs/Threads.h
+++ b/CommonLibs/Threads.h
@@ -172,8 +172,15 @@ class Thread {
void start(void *(*task)(void*), void *arg);
/** Join a thread that will stop on its own. */
- void join() { int s = pthread_join(mThread,NULL); assert(!s); mThread = 0; }
+ void join() {
+ if (mThread) {
+ int s = pthread_join(mThread, NULL);
+ assert(!s);
+ }
+ }
+ /** Send cancelation to thread */
+ void cancel() { pthread_cancel(mThread); }
};