/root/doris/be/src/pipeline/task_scheduler.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <stddef.h> |
21 | | |
22 | | #include <atomic> |
23 | | #include <condition_variable> |
24 | | #include <list> |
25 | | #include <memory> |
26 | | #include <mutex> |
27 | | #include <utility> |
28 | | #include <vector> |
29 | | |
30 | | #include "common/status.h" |
31 | | #include "gutil/ref_counted.h" |
32 | | #include "pipeline_task.h" |
33 | | #include "runtime/workload_group/workload_group.h" |
34 | | #include "task_queue.h" |
35 | | #include "util/thread.h" |
36 | | |
37 | | namespace doris { |
38 | | class ExecEnv; |
39 | | class ThreadPool; |
40 | | } // namespace doris |
41 | | |
42 | | namespace doris::pipeline { |
43 | | |
44 | | class TaskScheduler { |
45 | | public: |
46 | | TaskScheduler(int core_num, std::string name, std::shared_ptr<CgroupCpuCtl> cgroup_cpu_ctl) |
47 | | : _task_queue(core_num), |
48 | | _shutdown(false), |
49 | | _name(std::move(name)), |
50 | 0 | _cgroup_cpu_ctl(cgroup_cpu_ctl) {} |
51 | | |
52 | | ~TaskScheduler(); |
53 | | |
54 | | Status schedule_task(PipelineTask* task); |
55 | | |
56 | | Status start(); |
57 | | |
58 | | void stop(); |
59 | | |
60 | 0 | std::vector<int> thread_debug_info() { return _fix_thread_pool->debug_info(); } |
61 | | |
62 | | private: |
63 | | std::unique_ptr<ThreadPool> _fix_thread_pool; |
64 | | MultiCoreTaskQueue _task_queue; |
65 | | std::vector<bool> _markers; |
66 | | bool _shutdown; |
67 | | std::string _name; |
68 | | std::weak_ptr<CgroupCpuCtl> _cgroup_cpu_ctl; |
69 | | |
70 | | void _do_work(int index); |
71 | | }; |
72 | | } // namespace doris::pipeline |