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

Unified Diff: base/message_loop/message_pump_default.h

Issue 558553002: Use CondVar+Lock+bool instead of WaitableEvent for MessagePumpDefault on posix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@post_perftest
Patch Set: Created 6 years, 3 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 | « no previous file | base/message_loop/message_pump_default.cc » ('j') | base/message_loop/message_pump_default.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_default.h
diff --git a/base/message_loop/message_pump_default.h b/base/message_loop/message_pump_default.h
index 19e720013fd69ca635bfa9801d114236562d83cc..581f308a9de6fc7da523d822e12bd1ac4904080c 100644
--- a/base/message_loop/message_pump_default.h
+++ b/base/message_loop/message_pump_default.h
@@ -7,6 +7,8 @@
#include "base/base_export.h"
#include "base/message_loop/message_pump.h"
+#include "base/synchronization/condition_variable.h"
+#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
@@ -24,11 +26,23 @@ class BASE_EXPORT MessagePumpDefault : public MessagePump {
virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
private:
+ void Wait();
+ void TimedWait(const TimeDelta& max_time);
+ void Signal();
+
// This flag is set to false when Run should return.
bool keep_running_;
+#if defined(OS_WIN)
// Used to sleep until there is more work to do.
WaitableEvent event_;
+#elif defined(OS_POSIX)
+ Lock lock_; // Protects needs_wake_up_ and cv_;
+ bool needs_wake_up_;
+ ConditionVariable cv_;
+#else
+#error Need implementation for your platform
+#endif
// The time at which we should call DoDelayedWork.
TimeTicks delayed_work_time_;
« no previous file with comments | « no previous file | base/message_loop/message_pump_default.cc » ('j') | base/message_loop/message_pump_default.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698