Index: webrtc/base/platform_thread.cc |
diff --git a/webrtc/base/platform_thread.cc b/webrtc/base/platform_thread.cc |
index 0b025f2af048f94d9e776f171276850f54ef952e..12420f17b983600520b6ab6fa91c8466ed4c1b46 100644 |
--- a/webrtc/base/platform_thread.cc |
+++ b/webrtc/base/platform_thread.cc |
@@ -10,6 +10,7 @@ |
#include "webrtc/base/platform_thread.h" |
+#include "webrtc/base/atomicops.h" |
#include "webrtc/base/checks.h" |
#if defined(WEBRTC_LINUX) |
@@ -96,15 +97,7 @@ PlatformThread::PlatformThread(ThreadRunFunction func, |
const char* thread_name) |
: run_function_(func), |
obj_(obj), |
- name_(thread_name ? thread_name : "webrtc"), |
-#if defined(WEBRTC_WIN) |
- stop_(false), |
- thread_(NULL), |
- thread_id_(0) { |
-#else |
- stop_event_(false, false), |
- thread_(0) { |
-#endif // defined(WEBRTC_WIN) |
+ name_(thread_name ? thread_name : "webrtc") { |
RTC_DCHECK(func); |
RTC_DCHECK(name_.length() < 64); |
} |
@@ -187,8 +180,9 @@ void PlatformThread::Stop() { |
thread_ = nullptr; |
thread_id_ = 0; |
#else |
- stop_event_.Set(); |
+ RTC_CHECK_EQ(1, AtomicOps::Increment(&stop_flag_)); |
RTC_CHECK_EQ(0, pthread_join(thread_, nullptr)); |
+ AtomicOps::ReleaseStore(&stop_flag_, 0); |
thread_ = 0; |
#endif // defined(WEBRTC_WIN) |
} |
@@ -207,7 +201,7 @@ void PlatformThread::Run() { |
SleepEx(0, true); |
} while (!stop_); |
#else |
the sun
2017/02/18 23:18:25
Do we want to give up the reminder of our time sli
|
- } while (!stop_event_.Wait(0)); |
+ } while (!AtomicOps::AcquireLoad(&stop_flag_)); |
#endif // defined(WEBRTC_WIN) |
} |