Coverage Report

Created: 2025-04-14 12:46

/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 "util/thread.h"
35
36
namespace doris {
37
class ExecEnv;
38
class ThreadPool;
39
40
namespace pipeline {
41
class TaskQueue;
42
} // namespace pipeline
43
} // namespace doris
44
45
namespace doris::pipeline {
46
47
class TaskScheduler {
48
public:
49
    TaskScheduler(ExecEnv* exec_env, std::shared_ptr<TaskQueue> task_queue, std::string name,
50
                  CgroupCpuCtl* cgroup_cpu_ctl)
51
            : _task_queue(std::move(task_queue)),
52
              _shutdown(false),
53
              _name(std::move(name)),
54
0
              _cgroup_cpu_ctl(cgroup_cpu_ctl) {}
55
56
    ~TaskScheduler();
57
58
    Status schedule_task(PipelineTask* task);
59
60
    Status start();
61
62
    void stop();
63
64
0
    std::vector<int> thread_debug_info() { return _fix_thread_pool->debug_info(); }
65
66
private:
67
    std::unique_ptr<ThreadPool> _fix_thread_pool;
68
    std::shared_ptr<TaskQueue> _task_queue;
69
    std::vector<bool> _markers;
70
    bool _shutdown;
71
    std::string _name;
72
    CgroupCpuCtl* _cgroup_cpu_ctl = nullptr;
73
74
    void _do_work(size_t index);
75
};
76
} // namespace doris::pipeline