| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_TASK_RUNNER_H_ | 5 #ifndef BASE_TASK_RUNNER_H_ |
| 6 #define BASE_TASK_RUNNER_H_ | 6 #define BASE_TASK_RUNNER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // - A TaskRunner that stores the list of posted tasks and has a | 54 // - A TaskRunner that stores the list of posted tasks and has a |
| 55 // method Run() that runs each runnable task in random order. | 55 // method Run() that runs each runnable task in random order. |
| 56 class BASE_EXPORT TaskRunner | 56 class BASE_EXPORT TaskRunner |
| 57 : public RefCountedThreadSafe<TaskRunner, TaskRunnerTraits> { | 57 : public RefCountedThreadSafe<TaskRunner, TaskRunnerTraits> { |
| 58 public: | 58 public: |
| 59 // Posts the given task to be run. Returns true if the task may be | 59 // Posts the given task to be run. Returns true if the task may be |
| 60 // run at some point in the future, and false if the task definitely | 60 // run at some point in the future, and false if the task definitely |
| 61 // will not be run. | 61 // will not be run. |
| 62 // | 62 // |
| 63 // Equivalent to PostDelayedTask(from_here, task, 0). | 63 // Equivalent to PostDelayedTask(from_here, task, 0). |
| 64 bool PostTask(const tracked_objects::Location& from_here, | 64 bool PostTask(const tracked_objects::Location& from_here, Closure task); |
| 65 const Closure& task); | |
| 66 | 65 |
| 67 // Like PostTask, but tries to run the posted task only after | 66 // Like PostTask, but tries to run the posted task only after |
| 68 // |delay_ms| has passed. | 67 // |delay_ms| has passed. |
| 69 // | 68 // |
| 70 // It is valid for an implementation to ignore |delay_ms|; that is, | 69 // It is valid for an implementation to ignore |delay_ms|; that is, |
| 71 // to have PostDelayedTask behave the same as PostTask. | 70 // to have PostDelayedTask behave the same as PostTask. |
| 72 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 71 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 73 const Closure& task, | 72 Closure task, |
| 74 base::TimeDelta delay) = 0; | 73 base::TimeDelta delay) = 0; |
| 75 | 74 |
| 76 // Returns true if the current thread is a thread on which a task | 75 // Returns true if the current thread is a thread on which a task |
| 77 // may be run, and false if no task will be run on the current | 76 // may be run, and false if no task will be run on the current |
| 78 // thread. | 77 // thread. |
| 79 // | 78 // |
| 80 // It is valid for an implementation to always return true, or in | 79 // It is valid for an implementation to always return true, or in |
| 81 // general to use 'true' as a default value. | 80 // general to use 'true' as a default value. |
| 82 virtual bool RunsTasksOnCurrentThread() const = 0; | 81 virtual bool RunsTasksOnCurrentThread() const = 0; |
| 83 | 82 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 virtual void OnDestruct() const; | 141 virtual void OnDestruct() const; |
| 143 }; | 142 }; |
| 144 | 143 |
| 145 struct BASE_EXPORT TaskRunnerTraits { | 144 struct BASE_EXPORT TaskRunnerTraits { |
| 146 static void Destruct(const TaskRunner* task_runner); | 145 static void Destruct(const TaskRunner* task_runner); |
| 147 }; | 146 }; |
| 148 | 147 |
| 149 } // namespace base | 148 } // namespace base |
| 150 | 149 |
| 151 #endif // BASE_TASK_RUNNER_H_ | 150 #endif // BASE_TASK_RUNNER_H_ |
| OLD | NEW |