diff options
Diffstat (limited to 'test/test_blocking_counter.cc')
-rw-r--r-- | test/test_blocking_counter.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/test_blocking_counter.cc b/test/test_blocking_counter.cc index 8260576..d1e0932 100644 --- a/test/test_blocking_counter.cc +++ b/test/test_blocking_counter.cc @@ -1,4 +1,4 @@ -// Copyright 2015 Google Inc. All Rights Reserved. +// Copyright 2015 The Gemmlowp Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ // limitations under the License. #include "test.h" +#include "../profiling/pthread_everywhere.h" -#include <pthread.h> #include <vector> #include "../internal/multi_thread_gemm.h" @@ -26,6 +26,7 @@ class Thread { Thread(BlockingCounter* blocking_counter, int number_of_times_to_decrement) : blocking_counter_(blocking_counter), number_of_times_to_decrement_(number_of_times_to_decrement), + finished_(false), made_the_last_decrement_(false) { pthread_create(&thread_, nullptr, ThreadFunc, this); } @@ -33,7 +34,9 @@ class Thread { ~Thread() { Join(); } bool Join() const { - pthread_join(thread_, nullptr); + if (!finished_) { + pthread_join(thread_, nullptr); + } return made_the_last_decrement_; } @@ -45,6 +48,7 @@ class Thread { Check(!made_the_last_decrement_); made_the_last_decrement_ = blocking_counter_->DecrementCount(); } + finished_ = true; } static void* ThreadFunc(void* ptr) { @@ -55,6 +59,7 @@ class Thread { BlockingCounter* const blocking_counter_; const int number_of_times_to_decrement_; pthread_t thread_; + bool finished_; bool made_the_last_decrement_; }; |