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_QOS_H 17 #define FFRT_QOS_H 18 19 #include "ffrt_inner.h" 20 21 constexpr unsigned char NR_QOS = 6; 22 23 namespace ffrt { 24 25 typedef int (*Func_qos_map)(int qos); 26 void SetFuncQosMap(Func_qos_map func); 27 Func_qos_map GetFuncQosMap(void); 28 29 int QoSMap(int qos); 30 31 typedef int (*Func_qos_max)(void); 32 void SetFuncQosMax(Func_qos_max func); 33 Func_qos_max GetFuncQosMax(void); 34 35 int QoSMax(void); 36 37 class QoS { 38 public: 39 QoS(int qos = qos_default) 40 { 41 if (qos < static_cast<int>(qos_inherit)) { 42 qos = qos_inherit; 43 } else if (qos > static_cast<int>(qos_max)) { 44 qos = qos_max; 45 } 46 qos_ = qos; 47 } 48 QoS(const QoS & qos)49 QoS(const QoS& qos) : qos_(qos()) 50 { 51 } 52 operator()53 int operator()() const 54 { 55 return qos_; 56 } 57 58 operator int() const 59 { 60 return qos_; 61 } 62 Min()63 static constexpr int Min() 64 { 65 return qos_background; 66 } 67 Max()68 static int Max() 69 { 70 return qos_max + 1; 71 } 72 MaxNum()73 static constexpr int MaxNum() 74 { 75 return qos_max + 1; 76 } 77 78 private: 79 int qos_; 80 }; 81 }; // namespace ffrt 82 #endif