diff --git a/webrtc/system_wrappers/source/thread_posix.cc b/webrtc/system_wrappers/source/thread_posix.cc index 4050c82bd..0341338ab 100644 --- a/webrtc/system_wrappers/source/thread_posix.cc +++ b/webrtc/system_wrappers/source/thread_posix.cc @@ -82,7 +82,7 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj, : run_function_(func), obj_(obj), prio_(prio), - stop_event_(EventWrapper::Create()), + stop_event_(true, false), name_(thread_name ? thread_name : "webrtc"), thread_id_(0), thread_(0) { @@ -126,10 +126,10 @@ bool ThreadPosix::Stop() { if (!thread_id_) return true; - stop_event_->Set(); + stop_event_.Set(); CHECK_EQ(0, pthread_join(thread_, nullptr)); thread_id_ = 0; - stop_event_->Reset(); + stop_event_.Reset(); return true; } @@ -175,7 +175,7 @@ void ThreadPosix::Run(ThreadPosix::InitParams* params) { do { if (!run_function_(obj_)) break; - } while (stop_event_->Wait(0) == kEventTimeout); + } while (!stop_event_.Wait(0)); } } // namespace webrtc diff --git a/webrtc/system_wrappers/source/thread_posix.h b/webrtc/system_wrappers/source/thread_posix.h index 88c55af02..ec9c10e98 100644 --- a/webrtc/system_wrappers/source/thread_posix.h +++ b/webrtc/system_wrappers/source/thread_posix.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ +#include "webrtc/base/event.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/base/thread_checker.h" #include "webrtc/system_wrappers/interface/thread_wrapper.h" @@ -19,9 +20,6 @@ namespace webrtc { -class CriticalSectionWrapper; -class EventWrapper; - int ConvertToSystemPriority(ThreadPriority priority, int min_prio, int max_prio); @@ -45,8 +43,7 @@ class ThreadPosix : public ThreadWrapper { ThreadRunFunction const run_function_; void* const obj_; ThreadPriority prio_; - // TODO(tommi): std::condition_variable? - const rtc::scoped_ptr stop_event_; + rtc::Event stop_event_; const std::string name_; pid_t thread_id_;