• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_CPU_MANAGER_INTERFACE_HPP
17 #define FFRT_CPU_MANAGER_INTERFACE_HPP
18 
19 #include "eu/worker_thread.h"
20 #include "qos.h"
21 #ifdef FFRT_IO_TASK_SCHEDULER
22 #include "sync/poller.h"
23 #endif
24 #include "tm/cpu_task.h"
25 
26 namespace ffrt {
27 enum class WorkerAction {
28     RETRY = 0,
29     RETIRE,
30     MAX,
31 };
32 
33 enum class TaskNotifyType {
34     TASK_PICKED = 0,
35     TASK_ADDED,
36 #ifdef FFRT_IO_TASK_SCHEDULER
37     TASK_LOCAL,
38 #endif
39 };
40 
41 enum class SleepType {
42     SLEEP_UNTIL_WAKEUP = 0,
43     SLEEP_UNTIL_INTERRUPT,
44 };
45 
46 struct CpuWorkerOps {
47     std::function<CPUEUTask* (WorkerThread*)> PickUpTask;
48     std::function<void (const WorkerThread*)> NotifyTaskPicked;
49     std::function<WorkerAction (const WorkerThread*)> WaitForNewAction;
50     std::function<void (WorkerThread*)> WorkerRetired;
51     std::function<void (WorkerThread*)> WorkerPrepare;
52 #ifdef FFRT_IO_TASK_SCHEDULER
53     std::function<PollerRet (const WorkerThread*, int timeout)> TryPoll;
54     std::function<unsigned int (WorkerThread*)> StealTaskBatch;
55     std::function<CPUEUTask* (WorkerThread*)> PickUpTaskBatch;
56     std::function<void (WorkerThread*)> TryMoveLocal2Global;
57 #endif
58 };
59 
60 struct CpuMonitorOps {
61     std::function<bool (const QoS& qos)> IncWorker;
62     std::function<void (const QoS& qos)> WakeupWorkers;
63     std::function<int (const QoS& qos)> GetTaskCount;
64     std::function<int (const QoS& qos)> GetWorkerCount;
65 };
66 }
67 #endif
68