Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #ifndef CHROME_COMMON_TASK_QUEUE_H__ |
michael@0 | 6 | #define CHROME_COMMON_TASK_QUEUE_H__ |
michael@0 | 7 | |
michael@0 | 8 | #include <deque> |
michael@0 | 9 | |
michael@0 | 10 | #include "base/task.h" |
michael@0 | 11 | |
michael@0 | 12 | // A TaskQueue is a queue of tasks waiting to be run. To run the tasks, call |
michael@0 | 13 | // the Run method. A task queue is itself a Task so that it can be placed in a |
michael@0 | 14 | // message loop or another task queue. |
michael@0 | 15 | class TaskQueue : public Task { |
michael@0 | 16 | public: |
michael@0 | 17 | TaskQueue(); |
michael@0 | 18 | ~TaskQueue(); |
michael@0 | 19 | |
michael@0 | 20 | // Run all the tasks in the queue. New tasks pushed onto the queue during |
michael@0 | 21 | // a run will be run next time |Run| is called. |
michael@0 | 22 | virtual void Run(); |
michael@0 | 23 | |
michael@0 | 24 | // Push the specified task onto the queue. When the queue is run, the tasks |
michael@0 | 25 | // will be run in the order they are pushed. |
michael@0 | 26 | // |
michael@0 | 27 | // This method takes ownership of |task| and will delete task after it is run |
michael@0 | 28 | // (or when the TaskQueue is destroyed, if we never got a chance to run it). |
michael@0 | 29 | void Push(Task* task); |
michael@0 | 30 | |
michael@0 | 31 | // Remove all tasks from the queue. The tasks are deleted. |
michael@0 | 32 | void Clear(); |
michael@0 | 33 | |
michael@0 | 34 | // Returns true if this queue contains no tasks. |
michael@0 | 35 | bool Empty() const; |
michael@0 | 36 | |
michael@0 | 37 | private: |
michael@0 | 38 | // The list of tasks we are waiting to run. |
michael@0 | 39 | std::deque<Task*> queue_; |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | #endif // CHROME_COMMON_TASK_QUEUE_H__ |