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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_ 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/message_loop/message_pump.h" 9 #include "base/message_loop/message_pump.h"
10 #include "base/synchronization/condition_variable.h"
11 #include "base/synchronization/lock.h"
10 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
11 #include "base/time/time.h" 13 #include "base/time/time.h"
12 14
13 namespace base { 15 namespace base {
14 16
15 class BASE_EXPORT MessagePumpDefault : public MessagePump { 17 class BASE_EXPORT MessagePumpDefault : public MessagePump {
16 public: 18 public:
17 MessagePumpDefault(); 19 MessagePumpDefault();
18 virtual ~MessagePumpDefault(); 20 virtual ~MessagePumpDefault();
19 21
20 // MessagePump methods: 22 // MessagePump methods:
21 virtual void Run(Delegate* delegate) OVERRIDE; 23 virtual void Run(Delegate* delegate) OVERRIDE;
22 virtual void Quit() OVERRIDE; 24 virtual void Quit() OVERRIDE;
23 virtual void ScheduleWork() OVERRIDE; 25 virtual void ScheduleWork() OVERRIDE;
24 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE; 26 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
25 27
26 private: 28 private:
29 void Wait();
30 void TimedWait(const TimeDelta& max_time);
31 void Signal();
32
27 // This flag is set to false when Run should return. 33 // This flag is set to false when Run should return.
28 bool keep_running_; 34 bool keep_running_;
29 35
36 #if defined(OS_WIN)
30 // Used to sleep until there is more work to do. 37 // Used to sleep until there is more work to do.
31 WaitableEvent event_; 38 WaitableEvent event_;
39 #elif defined(OS_POSIX)
40 Lock lock_; // Protects needs_wake_up_ and cv_;
41 bool needs_wake_up_;
42 ConditionVariable cv_;
43 #else
44 #error Need implementation for your platform
45 #endif
32 46
33 // The time at which we should call DoDelayedWork. 47 // The time at which we should call DoDelayedWork.
34 TimeTicks delayed_work_time_; 48 TimeTicks delayed_work_time_;
35 49
36 DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault); 50 DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault);
37 }; 51 };
38 52
39 } // namespace base 53 } // namespace base
40 54
41 #endif // BASE__MESSAGE_LOOPMESSAGE_PUMP_DEFAULT_H_ 55 #endif // BASE__MESSAGE_LOOPMESSAGE_PUMP_DEFAULT_H_
OLDNEW
« 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