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

Side by Side Diff: base/task_scheduler/task_scheduler_impl.h

Issue 1685423002: Task Scheduler. (Closed) Base URL: https://luckyluke-private.googlesource.com/src@a_master
Patch Set: Created 4 years, 10 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 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
7
8 #include "base/base_export.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/task_scheduler/sequence.h"
13 #include "base/task_scheduler/shutdown_manager.h"
14 #include "base/task_scheduler/task_scheduler.h"
15 #include "base/task_scheduler/thread_pool.h"
16
17 namespace base {
18 namespace task_scheduler {
19
20 class WorkerThread;
21
22 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
23 public:
24 TaskSchedulerImpl();
25 ~TaskSchedulerImpl() override;
26
27 // TaskScheduler:
28 void PostTaskWithTraits(const tracked_objects::Location& from_here,
29 TaskTraits traits,
30 const Closure& task) override;
31 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
32 TaskTraits traits,
33 ExecutionMode execution_mode) override;
34 void Shutdown() override;
35
36 // Waits until all threads have exited. Shutdown() must have been called
37 // before this is called, otherwise the threads won't exit.
38 void JoinAllThreadsForTesting();
robliao 2016/02/11 21:56:27 Is it ever valid to call this without calling Shut
fdoray 2016/02/12 04:16:20 Done.
39
40 private:
41 // Returns the thread pool that should run tasks with |traits|.
42 ThreadPool* GetThreadPoolForTraits(const TaskTraits& traits);
43
44 // Callback invoked by |worker_thread| to reinsert |sequence| in the
45 // appropriate priority queue after it has executed one of its tasks.
46 void ReinsertSequenceCallback(
47 scoped_refptr<task_scheduler::Sequence> sequence,
48 const task_scheduler::WorkerThread* worker_thread);
49
50 ShutdownManager shutdown_manager_;
51
52 scoped_ptr<ThreadPool> background_thread_pool_;
53 scoped_ptr<ThreadPool> background_file_io_thread_pool_;
54 scoped_ptr<ThreadPool> normal_thread_pool_;
55 scoped_ptr<ThreadPool> normal_file_io_thread_pool_;
56
57 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl);
58 };
59
60 } // namespace task_scheduler
61 } // namespace base
62
63 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698