/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FFRT_CPU_MANAGER_STRATEGY_HPP #define FFRT_CPU_MANAGER_STRATEGY_HPP #include "eu/worker_thread.h" #include "qos.h" #include "sync/poller.h" #include "tm/cpu_task.h" namespace ffrt { enum class WorkerAction { RETRY = 0, RETIRE, MAX, }; enum class TaskNotifyType { TASK_PICKED = 0, TASK_ADDED, TASK_LOCAL, TASK_ESCAPED, }; struct CpuWorkerOps { std::function WorkerLooper; std::function PickUpTask; std::function NotifyTaskPicked; std::function WaitForNewAction; std::function WorkerRetired; std::function WorkerPrepare; std::function TryPoll; std::function StealTaskBatch; std::function PickUpTaskBatch; #ifdef FFRT_WORKERS_DYNAMIC_SCALING std::function IsExceedRunningThreshold; std::function IsBlockAwareInit; #endif }; struct CpuMonitorOps { std::function IncWorker; std::function WakeupWorkers; std::function GetTaskCount; std::function GetWorkerCount; std::function HandleTaskNotity; }; class CPUMonitor; class CPUManagerStrategy { public: static WorkerThread* CreateCPUWorker(const QoS& qos, void* manager); static CPUMonitor* CreateCPUMonitor(void* manager); }; } #endif