OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef BASE_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 bool nestable; // True if OK to dispatch from a nested loop. | 262 bool nestable; // True if OK to dispatch from a nested loop. |
263 | 263 |
264 PendingTask(Task* task, bool nestable) | 264 PendingTask(Task* task, bool nestable) |
265 : task(task), sequence_num(0), nestable(nestable) { | 265 : task(task), sequence_num(0), nestable(nestable) { |
266 } | 266 } |
267 | 267 |
268 // Used to support sorting. | 268 // Used to support sorting. |
269 bool operator<(const PendingTask& other) const; | 269 bool operator<(const PendingTask& other) const; |
270 }; | 270 }; |
271 | 271 |
| 272 // TEMP HACK: This is the same as std::less, except it has a data member. |
| 273 // This should cause its storage to be initialized, therefore avoiding a |
| 274 // UMR in pop(). Experiment for crbug.com/5555. |
| 275 template<class T> |
| 276 struct LessComparatorHack { |
| 277 LessComparatorHack() : junk(42) {} |
| 278 bool operator()(const T& a, const T& b) const { return a < b; } |
| 279 int junk; |
| 280 }; |
| 281 |
272 typedef std::queue<PendingTask> TaskQueue; | 282 typedef std::queue<PendingTask> TaskQueue; |
273 typedef std::priority_queue<PendingTask> DelayedTaskQueue; | 283 typedef std::priority_queue<PendingTask, std::vector<PendingTask>, |
| 284 LessComparatorHack<PendingTask> > DelayedTaskQueue; |
274 | 285 |
275 #if defined(OS_WIN) | 286 #if defined(OS_WIN) |
276 base::MessagePumpWin* pump_win() { | 287 base::MessagePumpWin* pump_win() { |
277 return static_cast<base::MessagePumpWin*>(pump_.get()); | 288 return static_cast<base::MessagePumpWin*>(pump_.get()); |
278 } | 289 } |
279 #elif defined(OS_POSIX) | 290 #elif defined(OS_POSIX) |
280 base::MessagePumpLibevent* pump_libevent() { | 291 base::MessagePumpLibevent* pump_libevent() { |
281 return static_cast<base::MessagePumpLibevent*>(pump_.get()); | 292 return static_cast<base::MessagePumpLibevent*>(pump_.get()); |
282 } | 293 } |
283 #endif | 294 #endif |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 #endif // defined(OS_POSIX) | 495 #endif // defined(OS_POSIX) |
485 }; | 496 }; |
486 | 497 |
487 // Do not add any member variables to MessageLoopForIO! This is important b/c | 498 // Do not add any member variables to MessageLoopForIO! This is important b/c |
488 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 499 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
489 // data that you need should be stored on the MessageLoop's pump_ instance. | 500 // data that you need should be stored on the MessageLoop's pump_ instance. |
490 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 501 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
491 MessageLoopForIO_should_not_have_extra_member_variables); | 502 MessageLoopForIO_should_not_have_extra_member_variables); |
492 | 503 |
493 #endif // BASE_MESSAGE_LOOP_H_ | 504 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |