Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: base/task_runner.h

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: fixed build error and commments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 // Like PostTask, but tries to run the posted task only after 66 // Like PostTask, but tries to run the posted task only after
67 // |delay_ms| has passed. 67 // |delay_ms| has passed.
68 // 68 //
69 // 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,
70 // to have PostDelayedTask behave the same as PostTask. 70 // to have PostDelayedTask behave the same as PostTask.
71 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, 71 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
72 OnceClosure task, 72 OnceClosure task,
73 base::TimeDelta delay) = 0; 73 base::TimeDelta delay) = 0;
74 74
75 // Returns true if the current thread is a thread on which a task 75 // Drepecated: favor RunsTasksInCurrentSequence().
76 // may be run, and false if no task will be run on the current 76 // TODO(http://crbug.com/665062): mass redirect callers and remove this.
77 // thread. 77 bool RunsTasksOnCurrentThread() const;
78
79 // Returns true iff tasks posted to this TaskRunner are sequenced
80 // with this call.
78 // 81 //
79 // It is valid for an implementation to always return true, or in 82 // In particular:
80 // general to use 'true' as a default value. 83 // - Returns true if this is a SequencedTaskRunner to which the
81 virtual bool RunsTasksOnCurrentThread() const = 0; 84 // current task was posted.
85 // - Returns true if this is a SequencedTaskRunner bound to the
86 // same sequence as the SequencedTaskRunner to which the current
87 // task was posted.
88 // - Returns true if this is a SingleThreadTaskRunner bound to
89 // the current thread.
90 // TODO(http://crbug.com/665062):
91 // This API doesn't make sense for parallel TaskRunners.
92 // Introduce alternate static APIs for documentation purposes of "this runs
93 // in pool X", have RunsTasksInCurrentSequence() return false for parallel
94 // TaskRunners, and ultimately move this method down to SequencedTaskRunner.
gab 2017/04/19 18:37:56 Indent last 4 lines by two extra spaces to make it
95 virtual bool RunsTasksInCurrentSequence() const = 0;
82 96
83 // Posts |task| on the current TaskRunner. On completion, |reply| 97 // Posts |task| on the current TaskRunner. On completion, |reply|
84 // is posted to the thread that called PostTaskAndReply(). Both 98 // is posted to the thread that called PostTaskAndReply(). Both
85 // |task| and |reply| are guaranteed to be deleted on the thread 99 // |task| and |reply| are guaranteed to be deleted on the thread
86 // from which PostTaskAndReply() is invoked. This allows objects 100 // from which PostTaskAndReply() is invoked. This allows objects
87 // that must be deleted on the originating thread to be bound into 101 // that must be deleted on the originating thread to be bound into
88 // the |task| and |reply| Closures. In particular, it can be useful 102 // the |task| and |reply| Closures. In particular, it can be useful
89 // to use WeakPtr<> in the |reply| Closure so that the reply 103 // to use WeakPtr<> in the |reply| Closure so that the reply
90 // operation can be canceled. See the following pseudo-code: 104 // operation can be canceled. See the following pseudo-code:
91 // 105 //
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 virtual void OnDestruct() const; 155 virtual void OnDestruct() const;
142 }; 156 };
143 157
144 struct BASE_EXPORT TaskRunnerTraits { 158 struct BASE_EXPORT TaskRunnerTraits {
145 static void Destruct(const TaskRunner* task_runner); 159 static void Destruct(const TaskRunner* task_runner);
146 }; 160 };
147 161
148 } // namespace base 162 } // namespace base
149 163
150 #endif // BASE_TASK_RUNNER_H_ 164 #endif // BASE_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698