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
16#ifndef QOS_H
17#define QOS_H
18/**
19 * @addtogroup QoS
20 * @{
21 *
22 * @brief QoS provides APIs.
23 *
24 * @since 12
25 */
26
27/**
28 * @file qos.h
29 *
30 * @brief Declares the QoS interfaces in C.
31 *
32 * Quality-of-service (QoS) refers to the priority scheduling attribute of tasks
33 * in OpenHarmony. Developers can use QoS to categorize tasks to be executed to
34 * indicate the degree of their relevance to user interactions, the system can
35 * schedule the time and running order of tasks according to the QoS set by the tasks.
36 *
37 * @library libqos.so
38 * @syscap SystemCapability.Resourceschedule.QoS.Core
39 * @since 12
40 */
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/**
46 * @brief Describes the level of QoS.
47 *
48 * @since 12
49 */
50typedef enum QoS_Level {
51    /**
52     * @brief Means the QoS level is background.
53     */
54    QOS_BACKGROUND = 0,
55
56    /**
57     * @brief Means the QoS level is utility.
58     */
59    QOS_UTILITY,
60
61    /**
62     * @brief Means the QoS level is default.
63     */
64    QOS_DEFAULT,
65
66    /**
67     * @brief Means the QoS level is user-initiated.
68     */
69    QOS_USER_INITIATED,
70
71    /**
72     * @brief Means the QoS level is user-request.
73     */
74    QOS_DEADLINE_REQUEST,
75
76    /**
77     * @brief Means the QoS level is user-interactive.
78     */
79    QOS_USER_INTERACTIVE,
80} QoS_Level;
81
82/**
83 * @brief Set the QoS level of the current thread.
84 *
85 * @param level Indicates the level to set. Specific level can be referenced {@link QoS_Level}.
86 * @return Returns int32_t, return value == 0, success, otherwise value == -1, failed.
87 * @see QoS_Level
88 * @since 12
89 */
90int OH_QoS_SetThreadQoS(QoS_Level level);
91
92/**
93 * @brief Cancel the QoS level of the current thread.
94 *
95 * @return Returns int32_t, return value == 0, success, otherwise value == -1, failed.
96 * @see QoS_Level
97 * @since 12
98 */
99int OH_QoS_ResetThreadQoS();
100
101/**
102 * @brief Obtains the QoS level of the current thread.
103 *
104 * @param level This parameter is the output parameter,
105 * and the QoS level of the thread as a {@link QoS_Level} is written to this variable.
106 * @return Returns int32_t, return value == 0, success, otherwise value == -1, failed.
107 * @see QoS_Level
108 * @since 12
109 */
110int OH_QoS_GetThreadQoS(QoS_Level *level);
111#ifdef __cplusplus
112};
113#endif
114#endif //QOS_H
115