• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FFRT_STASK_SCHEDULER_HPP
17 #define FFRT_STASK_SCHEDULER_HPP
18 #include "sched/task_scheduler.h"
19 
20 namespace ffrt {
21 class STaskScheduler : public TaskScheduler {
22 public:
STaskScheduler()23     STaskScheduler()
24     {
25         que = std::make_unique<FIFOQueue>();
26     }
27 
SetQos(QoS & q)28     void SetQos(QoS &q) override
29     {
30         qos = q;
31     }
32 
GetGlobalTaskCnt()33     uint64_t GetGlobalTaskCnt() override
34     {
35         return que->Size();
36     }
37 
38 private:
39     bool PushTaskGlobal(TaskBase* task, bool rtb) override;
40     TaskBase* PopTaskHybridProcess() override;
41 
PopTaskGlobal()42     TaskBase* PopTaskGlobal() override
43     {
44         TaskBase* task = nullptr;
45         {
46             // pop from global queue
47             std::lock_guard<std::mutex> lock(*GetMutex());
48             task = que->DeQueue();
49         }
50         if (task && task->type == ffrt_uv_task) {
51             return GetUVTask(task);
52         }
53         return task;
54     }
55 private:
56     std::unique_ptr<FIFOQueue> que { nullptr };
57 };
58 }
59 #endif
60