1 /* 2 * Copyright (c) 2024 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 #ifdef USE_OHOS_QOS 16 #include "qos.h" 17 #else 18 #include "staging_qos/sched/qos.h" 19 #endif 20 21 namespace ffrt { QoSMap(int qos)22int QoSMap(int qos) 23 { 24 if (qos <= static_cast<int>(qos_inherit)) { 25 return qos_inherit; 26 } else if (qos >= static_cast<int>(qos_background) && 27 qos <= static_cast<int>(qos_max)) { 28 return qos; 29 } else { 30 return qos_default; 31 } 32 } 33 34 static FuncQosMap funcQosMap = nullptr; SetFuncQosMap(FuncQosMap func)35void SetFuncQosMap(FuncQosMap func) 36 { 37 funcQosMap = func; 38 } 39 GetFuncQosMap(void)40FuncQosMap GetFuncQosMap(void) 41 { 42 return funcQosMap; 43 } 44 QoSMax(void)45int QoSMax(void) 46 { 47 return qos_max + 1; 48 } 49 50 static FuncQosMax funcQosMax = nullptr; SetFuncQosMax(FuncQosMax func)51void SetFuncQosMax(FuncQosMax func) 52 { 53 funcQosMax = func; 54 } 55 GetFuncQosMax(void)56FuncQosMax GetFuncQosMax(void) 57 { 58 return funcQosMax; 59 } 60 }