summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/message_loop.cc2
-rw-r--r--base/message_loop.h8
2 files changed, 8 insertions, 2 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 5464670..bf5256a 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -354,7 +354,7 @@ void MessageLoop::ReloadWorkQueue() {
AutoLock lock(incoming_queue_lock_);
if (incoming_queue_.empty())
return;
- std::swap(incoming_queue_, work_queue_);
+ incoming_queue_.Swap(&work_queue_); // Constant time
DCHECK(incoming_queue_.empty());
}
}
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)