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

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

Issue 1708773002: TaskScheduler [7] SchedulerThreadPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s_5_worker_thread
Patch Set: self review Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/task_scheduler/utils.h"
6
7 #include <utility>
8
9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
11 #include "base/task_scheduler/priority_queue.h"
12 #include "base/task_scheduler/sequence_sort_key.h"
13 #include "base/task_scheduler/task_tracker.h"
14
15 namespace base {
16 namespace internal {
17
18 bool PostTaskHelper(std::unique_ptr<Task> task,
danakj 2016/04/07 23:08:44 Can this be a method on SchedulerThreadPool? That
fdoray 2016/04/08 14:53:03 This method will also be used with single-threaded
danakj 2016/04/08 18:05:32 Why aren't single-threaded queues a SchedulerThrea
fdoray 2016/04/08 19:00:05 Each thread in a pool will get work from both the
fdoray 2016/04/11 14:25:46 Usage of this helper in DelayedTaskManager: https:
19 scoped_refptr<Sequence> sequence,
20 PriorityQueue* priority_queue,
21 TaskTracker* task_tracker) {
22 DCHECK(task);
23 DCHECK(sequence);
24 DCHECK(priority_queue);
25 DCHECK(task_tracker);
26
27 if (!task_tracker->WillPostTask(task.get()))
28 return false;
29
30 const bool sequence_was_empty = sequence->PushTask(std::move(task));
31 if (sequence_was_empty) {
32 // Insert |sequence| in |priority_queue| if it was empty before |task| was
33 // inserted into it. When that's not the case, one of these must be true:
34 // - |sequence| is already in a PriorityQueue, or,
35 // - A worker thread is running a Task from |sequence|. It will insert
36 // |sequence| in a PriorityQueue once it's done running the Task.
37 const SequenceSortKey sequence_sort_key = sequence->GetSortKey();
38 priority_queue->BeginTransaction()->Push(
39 WrapUnique(new PriorityQueue::SequenceAndSortKey(std::move(sequence),
40 sequence_sort_key)));
41 }
42
43 return true;
44 }
45
46 } // namespace internal
47 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698