Coverage Report

Created: 2025-03-10 22:58

/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 <atomic>
21
#include <chrono>
22
#include <condition_variable>
23
#include <cstddef>
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/query_context.h"
34
#include "runtime/workload_group/workload_group.h"
35
#include "task_queue.h"
36
#include "util/thread.h"
37
#include "util/uid_util.h"
38
39
namespace doris {
40
class ExecEnv;
41
class ThreadPool;
42
} // namespace doris
43
44
namespace doris::pipeline {
45
46
class TaskScheduler {
47
public:
48
    TaskScheduler(int core_num, std::string name, std::shared_ptr<CgroupCpuCtl> cgroup_cpu_ctl)
49
0
            : _task_queue(core_num), _name(std::move(name)), _cgroup_cpu_ctl(cgroup_cpu_ctl) {}
50
51
    ~TaskScheduler();
52
53
    Status schedule_task(PipelineTask* task);
54
55
    Status start();
56
57
    void stop();
58
59
0
    std::vector<int> thread_debug_info() { return _fix_thread_pool->debug_info(); }
60
61
private:
62
    std::unique_ptr<ThreadPool> _fix_thread_pool;
63
64
    MultiCoreTaskQueue _task_queue;
65
    bool _need_to_stop = false;
66
    bool _shutdown = false;
67
    std::string _name;
68
    std::weak_ptr<CgroupCpuCtl> _cgroup_cpu_ctl;
69
70
    void _do_work(int index);
71
};
72
} // namespace doris::pipeline