• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FFRT_API_CPP_DEADLINE_H
16 #define FFRT_API_CPP_DEADLINE_H
17 #include "../c/deadline.h"
18 
19 namespace ffrt {
20 using interval = ffrt_interval_t;
21 
22 /**
23     @brief app create an anonymous interval, the number is limited. should specify the deadline
24 */
25 static inline interval qos_interval_create(uint64_t deadline_us, qos qos_ = static_cast<int>(qos_deadline_request))
26 {
27     return ffrt_interval_create(deadline_us, qos_);
28 }
29 
30 /**
31     @brief destroy a interval
32 */
qos_interval_destroy(interval it)33 static inline void qos_interval_destroy(interval it)
34 {
35     ffrt_interval_destroy(it);
36 }
37 
38 /**
39     @brief start the interval
40 */
qos_interval_begin(interval it)41 static inline int qos_interval_begin(interval it)
42 {
43     return ffrt_interval_begin(it);
44 }
45 
46 /**
47     @brief update interval
48 */
qos_interval_update(interval it,uint64_t deadline_us)49 static inline int qos_interval_update(interval it, uint64_t deadline_us)
50 {
51     return ffrt_interval_update(it, deadline_us);
52 }
53 
54 /**
55     @brief interval become inactive until next begin
56 */
qos_interval_end(interval it)57 static inline int qos_interval_end(interval it)
58 {
59     return ffrt_interval_end(it);
60 }
61 
62 /**
63     @brief current task or thread join an interval, only allow FIXED number of threads to join a interval
64 */
qos_interval_join(interval it)65 static inline int qos_interval_join(interval it)
66 {
67     return ffrt_interval_join(it);
68 }
69 
70 /**
71     @brief current task or thread leave an interval
72 */
qos_interval_leave(interval it)73 static inline int qos_interval_leave(interval it)
74 {
75     return ffrt_interval_leave(it);
76 }
77 }; // namespace ffrt
78 
79 #endif
80