Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: webrtc/base/platform_thread.cc

Issue 2708433002: Replace the stop_event_ in PlatformThread with an atomic flag (Closed)
Patch Set: Update ProcessThreadImpl tests to not always return 0. Guessing it may be causing bot problems Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/platform_thread.h ('k') | webrtc/modules/utility/source/process_thread_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
}
« no previous file with comments | « webrtc/base/platform_thread.h ('k') | webrtc/modules/utility/source/process_thread_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698