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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 base::TimeDelta delay) = 0; | 74 base::TimeDelta delay) = 0; |
75 | 75 |
76 // Returns true if the current thread is a thread on which a task | 76 // 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 | 77 // may be run, and false if no task will be run on the current |
78 // thread. | 78 // thread. |
79 // | 79 // |
80 // It is valid for an implementation to always return true, or in | 80 // It is valid for an implementation to always return true, or in |
81 // general to use 'true' as a default value. | 81 // general to use 'true' as a default value. |
82 virtual bool RunsTasksOnCurrentThread() const = 0; | 82 virtual bool RunsTasksOnCurrentThread() const = 0; |
83 | 83 |
84 // Posts |task| on the current TaskRunner. On completion, |reply| | 84 // Posts |task| on the current TaskRunner. On completion, |reply| is posted |
85 // is posted to the thread that called PostTaskAndReply(). Both | 85 // to the sequence or thread that called PostTaskAndReply(). Can only be |
86 // |task| and |reply| are guaranteed to be deleted on the thread | 86 // called when SequencedTaskRunnerHandle::IsSet(). Both |task| and |reply| are |
87 // from which PostTaskAndReply() is invoked. This allows objects | 87 // guaranteed to be deleted on the sequence or thread from which |
88 // that must be deleted on the originating thread to be bound into | 88 // PostTaskAndReply() is invoked. This allows objects that must be deleted on |
robliao
2016/07/27 17:50:07
Nit, remove double space.
fdoray
2016/07/28 13:40:48
Done.
| |
89 // the |task| and |reply| Closures. In particular, it can be useful | 89 // the originating thread or sequence to be bound into the |task| and |reply| |
90 // to use WeakPtr<> in the |reply| Closure so that the reply | 90 // Closures. In particular, it can be useful to use WeakPtr<> in the |reply| |
91 // operation can be canceled. See the following pseudo-code: | 91 // Closure so that the reply operation can be canceled. See the following |
92 // pseudo-code: | |
92 // | 93 // |
93 // class DataBuffer : public RefCountedThreadSafe<DataBuffer> { | 94 // class DataBuffer : public RefCountedThreadSafe<DataBuffer> { |
94 // public: | 95 // public: |
95 // // Called to add data into a buffer. | 96 // // Called to add data into a buffer. |
96 // void AddData(void* buf, size_t length); | 97 // void AddData(void* buf, size_t length); |
97 // ... | 98 // ... |
98 // }; | 99 // }; |
99 // | 100 // |
100 // | 101 // |
101 // class DataLoader : public SupportsWeakPtr<DataLoader> { | 102 // class DataLoader : public SupportsWeakPtr<DataLoader> { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 virtual void OnDestruct() const; | 143 virtual void OnDestruct() const; |
143 }; | 144 }; |
144 | 145 |
145 struct BASE_EXPORT TaskRunnerTraits { | 146 struct BASE_EXPORT TaskRunnerTraits { |
146 static void Destruct(const TaskRunner* task_runner); | 147 static void Destruct(const TaskRunner* task_runner); |
147 }; | 148 }; |
148 | 149 |
149 } // namespace base | 150 } // namespace base |
150 | 151 |
151 #endif // BASE_TASK_RUNNER_H_ | 152 #endif // BASE_TASK_RUNNER_H_ |
OLD | NEW |