diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 21:38:44 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 21:38:44 +0000 |
commit | 7e3736e2e5b13502e1faafbe53ff0fffd55c3c8b (patch) | |
tree | 68251a0edefaca2a03e267bee1456dd80161a815 /base/message_loop | |
parent | 912d3900695a1b94385b465d6c311e0732e9a5db (diff) | |
download | chromium_src-7e3736e2e5b13502e1faafbe53ff0fffd55c3c8b.zip chromium_src-7e3736e2e5b13502e1faafbe53ff0fffd55c3c8b.tar.gz chromium_src-7e3736e2e5b13502e1faafbe53ff0fffd55c3c8b.tar.bz2 |
[Mac] Use a native MessagePump instead of a MessagePumpDefault
Many message loops in Chrome are backed by MessagePumpDefault which uses a WaitableEvent object to sleep, this is ultimately implemented as a pthread condition variable on POSIX.
In order to support timer coalescing in MessageLoops we need to sleep using a primitive which supports timer coalescing at the OS level (support for timer coalescing goes down into the kernel on Android/Linux/OSX/Win). The current change achieves this and should provide a way to gauge the effect of timer coalescing.
An alternate approach to this patch would be to implement MessagePumpDefault using a primitive which supports timer coalescing.
Local performance tests didn't uncover any regressions from this change.
BUG=356804
Review URL: https://codereview.chromium.org/331513002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop')
-rw-r--r-- | base/message_loop/message_loop.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc index dd1a393..ccece4d 100644 --- a/base/message_loop/message_loop.cc +++ b/base/message_loop/message_loop.cc @@ -229,6 +229,14 @@ scoped_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) { #define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI()) #endif +#if defined(OS_MACOSX) + // Use an OS native runloop on Mac to support timer coalescing. + #define MESSAGE_PUMP_DEFAULT \ + scoped_ptr<MessagePump>(new MessagePumpCFRunLoop()) +#else + #define MESSAGE_PUMP_DEFAULT scoped_ptr<MessagePump>(new MessagePumpDefault()) +#endif + if (type == MessageLoop::TYPE_UI) { if (message_pump_for_ui_factory_) return message_pump_for_ui_factory_(); @@ -243,7 +251,7 @@ scoped_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) { #endif DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type); - return scoped_ptr<MessagePump>(new MessagePumpDefault()); + return MESSAGE_PUMP_DEFAULT; } void MessageLoop::AddDestructionObserver( |