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