summaryrefslogtreecommitdiffstats
path: root/base/message_loop.h
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 20:05:21 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 20:05:21 +0000
commitb2f0ea1a109f6406d6633f51adb4621090b9032d (patch)
tree8e55db87473c159a3b33ab71091938298e9d1d52 /base/message_loop.h
parented157a21f003e2dd212d84fa81663c8fc95c8965 (diff)
downloadchromium_src-b2f0ea1a109f6406d6633f51adb4621090b9032d.zip
chromium_src-b2f0ea1a109f6406d6633f51adb4621090b9032d.tar.gz
chromium_src-b2f0ea1a109f6406d6633f51adb4621090b9032d.tar.bz2
Make swapping the incoming queue with the work queue constant time.
This is an alternative to the fix proposed here: http://codereview.chromium.org/172101 Credit goes to Dean McNamee for discovering this performance issue! R=deanm BUG=20204 TEST=none Review URL: http://codereview.chromium.org/190006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop.h')
-rw-r--r--base/message_loop.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/base/message_loop.h b/base/message_loop.h
index 395ce6e..d2fcc12 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -281,7 +281,13 @@ class MessageLoop : public base::MessagePump::Delegate {
bool operator<(const PendingTask& other) const;
};
- typedef std::queue<PendingTask> TaskQueue;
+ class TaskQueue : public std::queue<PendingTask> {
+ public:
+ void Swap(TaskQueue* queue) {
+ c.swap(queue->c); // Calls std::deque::swap
+ }
+ };
+
typedef std::priority_queue<PendingTask> DelayedTaskQueue;
#if defined(OS_WIN)