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

Side by Side Diff: base/task_scheduler/task_tracker.cc

Issue 2590443005: Add TaskTraits::MayBlock and TaskTraits::WithSyncPrimitives. (Closed)
Patch Set: fix build error 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "base/task_scheduler/task_tracker.h" 5 #include "base/task_scheduler/task_tracker.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/task_annotator.h" 10 #include "base/debug/task_annotator.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 task->traits.shutdown_behavior(); 218 task->traits.shutdown_behavior();
219 const bool can_run_task = BeforeRunTask(shutdown_behavior); 219 const bool can_run_task = BeforeRunTask(shutdown_behavior);
220 const bool is_delayed = !task->delayed_run_time.is_null(); 220 const bool is_delayed = !task->delayed_run_time.is_null();
221 221
222 if (can_run_task) { 222 if (can_run_task) {
223 const bool previous_singleton_allowed = 223 const bool previous_singleton_allowed =
224 ThreadRestrictions::SetSingletonAllowed( 224 ThreadRestrictions::SetSingletonAllowed(
225 task->traits.shutdown_behavior() != 225 task->traits.shutdown_behavior() !=
226 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); 226 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN);
227 const bool previous_io_allowed = 227 const bool previous_io_allowed =
228 ThreadRestrictions::SetIOAllowed(task->traits.with_file_io()); 228 ThreadRestrictions::SetIOAllowed(task->traits.may_block());
229 const bool previous_wait_allowed = 229 const bool previous_wait_allowed =
robliao 2016/12/19 22:04:56 Rename this while we're here.
fdoray 2016/12/20 13:32:24 This variable still contains the previous value of
230 ThreadRestrictions::SetWaitAllowed(task->traits.with_wait()); 230 ThreadRestrictions::SetWaitAllowed(task->traits.with_sync_primitives());
231 231
232 { 232 {
233 ScopedSetSequenceTokenForCurrentThread 233 ScopedSetSequenceTokenForCurrentThread
234 scoped_set_sequence_token_for_current_thread(sequence_token); 234 scoped_set_sequence_token_for_current_thread(sequence_token);
235 ScopedSetTaskPriorityForCurrentThread 235 ScopedSetTaskPriorityForCurrentThread
236 scoped_set_task_priority_for_current_thread(task->traits.priority()); 236 scoped_set_task_priority_for_current_thread(task->traits.priority());
237 237
238 // Set up TaskRunnerHandle as expected for the scope of the task. 238 // Set up TaskRunnerHandle as expected for the scope of the task.
239 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle; 239 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle;
240 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle; 240 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); 450 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1);
451 DCHECK_GE(new_num_pending_undelayed_tasks, 0); 451 DCHECK_GE(new_num_pending_undelayed_tasks, 0);
452 if (new_num_pending_undelayed_tasks == 0) { 452 if (new_num_pending_undelayed_tasks == 0) {
453 AutoSchedulerLock auto_lock(flush_lock_); 453 AutoSchedulerLock auto_lock(flush_lock_);
454 flush_cv_->Signal(); 454 flush_cv_->Signal();
455 } 455 }
456 } 456 }
457 457
458 } // namespace internal 458 } // namespace internal
459 } // namespace base 459 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698