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

Unified Diff: base/task_scheduler/task_traits.cc

Issue 2590443005: Add TaskTraits::MayBlock and TaskTraits::WithSyncPrimitives. (Closed)
Patch Set: self-review Created 4 years 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_scheduler/task_traits.cc
diff --git a/base/task_scheduler/task_traits.cc b/base/task_scheduler/task_traits.cc
index 9ebe821c827954be33cca6645924469db7495857..3cd6a61da69d2ada418db6e05f9d810f4a29be8b 100644
--- a/base/task_scheduler/task_traits.cc
+++ b/base/task_scheduler/task_traits.cc
@@ -17,23 +17,31 @@ namespace base {
// the header; anything else is subject to change. Tasks should explicitly
// request defaults if the behavior is critical to the task.
gab 2016/12/19 20:20:14 Move this comment and member initialization to mem
fdoray 2016/12/19 21:22:43 Unfortunately, these is an include cycle if I incl
TaskTraits::TaskTraits()
- : with_file_io_(false),
- with_wait_(false),
+ : may_block_(false),
+ with_sync_primitives_(false),
priority_(internal::GetTaskPriorityForCurrentThread()),
shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {}
TaskTraits::~TaskTraits() = default;
-TaskTraits& TaskTraits::WithFileIO() {
- with_file_io_ = true;
+TaskTraits& TaskTraits::MayBlock() {
+ may_block_ = true;
return *this;
}
-TaskTraits& TaskTraits::WithWait() {
- with_wait_ = true;
+TaskTraits& TaskTraits::WithSyncPrimitives() {
+ with_sync_primitives_ = true;
return *this;
}
+TaskTraits& TaskTraits::WithFileIO() {
+ return MayBlock();
+}
+
+TaskTraits& TaskTraits::WithWait() {
+ return MayBlock().WithSyncPrimitives();
+}
+
TaskTraits& TaskTraits::WithPriority(TaskPriority priority) {
priority_ = priority;
return *this;

Powered by Google App Engine
This is Rietveld 408576698