ipc/chromium/src/chrome/common/task_queue.cc

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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
     3 // found in the LICENSE file.
     5 #include "chrome/common/task_queue.h"
     7 #include "base/stl_util-inl.h"
     9 TaskQueue::TaskQueue() {
    10 }
    12 TaskQueue::~TaskQueue() {
    13   // We own all the pointes in |queue_|.  It is our job to delete them.
    14   STLDeleteElements(&queue_);
    15 }
    17 void TaskQueue::Run() {
    18   // Nothing to run if our queue is empty.
    19   if (queue_.empty())
    20     return;
    22   std::deque<Task*> ready;
    23   queue_.swap(ready);
    25   // Run the tasks that are ready.
    26   std::deque<Task*>::const_iterator task;
    27   for (task = ready.begin(); task != ready.end(); ++task) {
    28     // Run the task and then delete it.
    29     (*task)->Run();
    30     delete (*task);
    31   }
    32 }
    34 void TaskQueue::Push(Task* task) {
    35   // Add the task to the back of the queue.
    36   queue_.push_back(task);
    37 }
    39 void TaskQueue::Clear() {
    40   // Delete all the elements in the queue and clear the dead pointers.
    41   STLDeleteElements(&queue_);
    42 }
    44 bool TaskQueue::Empty() const {
    45   return queue_.empty();
    46 }

mercurial