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 Func_qos_map func_qos_map = nullptr; SetFuncQosMap(Func_qos_map func)31void SetFuncQosMap(Func_qos_map func) 32 { 33 func_qos_map = func; 34 } 35 GetFuncQosMap(void)36Func_qos_map GetFuncQosMap(void) 37 { 38 return func_qos_map; 39 } 40 QoSMax(void)41int QoSMax(void) 42 { 43 return qos_max + 1; 44 } 45 46 static Func_qos_max func_qos_max = nullptr; SetFuncQosMax(Func_qos_max func)47void SetFuncQosMax(Func_qos_max func) 48 { 49 func_qos_max = func; 50 } 51 GetFuncQosMax(void)52Func_qos_max GetFuncQosMax(void) 53 { 54 return func_qos_max; 55 } 56 }