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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/chrome/common/task_queue.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef CHROME_COMMON_TASK_QUEUE_H__
     1.9 +#define CHROME_COMMON_TASK_QUEUE_H__
    1.10 +
    1.11 +#include <deque>
    1.12 +
    1.13 +#include "base/task.h"
    1.14 +
    1.15 +// A TaskQueue is a queue of tasks waiting to be run.  To run the tasks, call
    1.16 +// the Run method.  A task queue is itself a Task so that it can be placed in a
    1.17 +// message loop or another task queue.
    1.18 +class TaskQueue : public Task {
    1.19 + public:
    1.20 +  TaskQueue();
    1.21 +  ~TaskQueue();
    1.22 +
    1.23 +  // Run all the tasks in the queue.  New tasks pushed onto the queue during
    1.24 +  // a run will be run next time |Run| is called.
    1.25 +  virtual void Run();
    1.26 +
    1.27 +  // Push the specified task onto the queue.  When the queue is run, the tasks
    1.28 +  // will be run in the order they are pushed.
    1.29 +  //
    1.30 +  // This method takes ownership of |task| and will delete task after it is run
    1.31 +  // (or when the TaskQueue is destroyed, if we never got a chance to run it).
    1.32 +  void Push(Task* task);
    1.33 +
    1.34 +  // Remove all tasks from the queue.  The tasks are deleted.
    1.35 +  void Clear();
    1.36 +
    1.37 +  // Returns true if this queue contains no tasks.
    1.38 +  bool Empty() const;
    1.39 +
    1.40 + private:
    1.41 +   // The list of tasks we are waiting to run.
    1.42 +   std::deque<Task*> queue_;
    1.43 +};
    1.44 +
    1.45 +#endif  // CHROME_COMMON_TASK_QUEUE_H__

mercurial