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 /**
17 * @file task.h
18 *
19 * @brief Declares the task inner interfaces in C++.
20 *
21 * @since 10
22 * @version 1.0
23 */
24 #ifndef FFRT_INNER_API_CPP_TASK_H
25 #define FFRT_INNER_API_CPP_TASK_H
26 #include <cstdint>
27 #include "c/task_ext.h"
28 #include "cpp/task.h"
29
30 namespace ffrt {
31 /**
32 * @brief Skips a task.
33 *
34 * @param handle Indicates a task handle.
35 * @return Returns <b>0</b> if the task is skipped;
36 returns <b>-1</b> otherwise.
37 * @since 10
38 * @version 1.0
39 */
skip(task_handle & handle)40 static inline int skip(task_handle &handle)
41 {
42 return ffrt_skip(handle);
43 }
44
45 void sync_io(int fd);
46
47 void set_trace_tag(const char* name);
48
49 void clear_trace_tag();
50
set_cgroup_attr(qos qos_,ffrt_os_sched_attr * attr)51 static inline int set_cgroup_attr(qos qos_, ffrt_os_sched_attr *attr)
52 {
53 return ffrt_set_cgroup_attr(qos_, attr);
54 }
55
restore_qos_config()56 static inline void restore_qos_config()
57 {
58 ffrt_restore_qos_config();
59 }
60
set_cpu_worker_max_num(qos qos_,uint32_t num)61 static inline int set_cpu_worker_max_num(qos qos_, uint32_t num)
62 {
63 return ffrt_set_cpu_worker_max_num(qos_, num);
64 }
65
66 /**
67 * @brief Notifies a specified number of workers at a specified QoS level.
68 *
69 * @param qos_ Indicates the QoS.
70 * @param number Indicates the number of workers to be notified.
71 * @version 1.0
72 */
notify_workers(qos qos_,int number)73 static inline void notify_workers(qos qos_, int number)
74 {
75 return ffrt_notify_workers(qos_, number);
76 }
77
78 /**
79 * @brief Obtains the ID of this queue.
80 *
81 * @return Returns the queue ID.
82 * @version 1.0
83 */
get_queue_id()84 static inline int64_t get_queue_id()
85 {
86 return ffrt_this_queue_get_id();
87 }
88 } // namespace ffrt
89 #endif
90