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

Unified Diff: base/task_runner.h

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: rebase & remove inline keyword Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: base/task_runner.h
diff --git a/base/task_runner.h b/base/task_runner.h
index 0421d564e6d75cdc8f7d763ba5c95a3b37169067..ac117919ba6ebe4591d93684e78f23eaacab8c8a 100644
--- a/base/task_runner.h
+++ b/base/task_runner.h
@@ -72,13 +72,29 @@ class BASE_EXPORT TaskRunner
OnceClosure task,
base::TimeDelta delay) = 0;
- // Returns true if the current thread is a thread on which a task
- // may be run, and false if no task will be run on the current
- // thread.
+ // Drepecated: favor RunsTasksInCurrentSequence().
+ // TODO(http://crbug.com/665062): mass redirect callers and remove this.
+ bool RunsTasksOnCurrentThread() const {
+ return RunsTasksInCurrentSequence();
+ }
+
+ // Returns true iff tasks posted to this TaskRunner are sequenced
+ // with this call.
//
- // It is valid for an implementation to always return true, or in
- // general to use 'true' as a default value.
- virtual bool RunsTasksOnCurrentThread() const = 0;
+ // In particular:
+ // - Returns true if this is a SequencedTaskRunner to which the
+ // current task was posted.
+ // - Returns true if this is a SequencedTaskRunner bound to the
+ // same sequence as the SequencedTaskRunner to which the current
+ // task was posted.
+ // - Returns true if this is a SingleThreadTaskRunner bound to
+ // the current thread.
+ // TODO(http://crbug.com/665062):
+ // This API doesn't make sense for parallel TaskRunners.
+ // Introduce alternate static APIs for documentation purposes of "this runs
+ // in pool X", have RunsTasksInCurrentSequence() return false for parallel
+ // TaskRunners, and ultimately move this method down to SequencedTaskRunner.
+ virtual bool RunsTasksInCurrentSequence() const = 0;
// Posts |task| on the current TaskRunner. On completion, |reply|
// is posted to the thread that called PostTaskAndReply(). Both
« no previous file with comments | « base/message_loop/message_loop_task_runner.cc ('k') | base/task_scheduler/scheduler_single_thread_task_runner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698