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

Side by Side Diff: base/message_loop.h

Issue 190006: Make swapping the incoming queue with the work queue constant time.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 bool nestable; // True if OK to dispatch from a nested loop. 274 bool nestable; // True if OK to dispatch from a nested loop.
275 275
276 PendingTask(Task* task, bool nestable) 276 PendingTask(Task* task, bool nestable)
277 : task(task), sequence_num(0), nestable(nestable) { 277 : task(task), sequence_num(0), nestable(nestable) {
278 } 278 }
279 279
280 // Used to support sorting. 280 // Used to support sorting.
281 bool operator<(const PendingTask& other) const; 281 bool operator<(const PendingTask& other) const;
282 }; 282 };
283 283
284 typedef std::queue<PendingTask> TaskQueue; 284 class TaskQueue : public std::queue<PendingTask> {
285 public:
286 void Swap(TaskQueue* queue) {
287 c.swap(queue->c);
eric.rannaud 2009/09/02 18:37:46 What is c?
288 }
289 };
290
285 typedef std::priority_queue<PendingTask> DelayedTaskQueue; 291 typedef std::priority_queue<PendingTask> DelayedTaskQueue;
286 292
287 #if defined(OS_WIN) 293 #if defined(OS_WIN)
288 base::MessagePumpWin* pump_win() { 294 base::MessagePumpWin* pump_win() {
289 return static_cast<base::MessagePumpWin*>(pump_.get()); 295 return static_cast<base::MessagePumpWin*>(pump_.get());
290 } 296 }
291 #elif defined(OS_POSIX) 297 #elif defined(OS_POSIX)
292 base::MessagePumpLibevent* pump_libevent() { 298 base::MessagePumpLibevent* pump_libevent() {
293 return static_cast<base::MessagePumpLibevent*>(pump_.get()); 299 return static_cast<base::MessagePumpLibevent*>(pump_.get());
294 } 300 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 #endif // defined(OS_POSIX) 510 #endif // defined(OS_POSIX)
505 }; 511 };
506 512
507 // Do not add any member variables to MessageLoopForIO! This is important b/c 513 // Do not add any member variables to MessageLoopForIO! This is important b/c
508 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 514 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
509 // data that you need should be stored on the MessageLoop's pump_ instance. 515 // data that you need should be stored on the MessageLoop's pump_ instance.
510 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 516 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
511 MessageLoopForIO_should_not_have_extra_member_variables); 517 MessageLoopForIO_should_not_have_extra_member_variables);
512 518
513 #endif // BASE_MESSAGE_LOOP_H_ 519 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698