1 // Copyright (c) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 //! A FFI crate for FFRT runtime.
15 
16 mod config;
17 mod sys_event;
18 mod task;
19 
20 pub use config::*;
21 use libc::{c_int, c_void};
22 pub use sys_event::*;
23 pub use task::*;
24 pub use {ffrt_get_current_task, ffrt_submit_coroutine};
25 
26 #[repr(C)]
27 #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
28 /// Qos levels.
29 pub enum Qos {
30     /// Inherits parent's qos level
31     Inherent = -1,
32     /// Lowest qos
33     Background,
34     /// Utility qos
35     Utility,
36     /// Default qos
37     Default,
38     /// User initialiated qos
39     UserInitiated,
40     /// Deadline qos
41     DeadlineRequest,
42     /// Highest qos
43     UserInteractive,
44 }
45 
46 #[repr(C)]
47 /// Dependencies for the task.
48 pub struct FfrtDeps {
49     len: u32,
50     items: *const *const c_void,
51 }
52 
53 #[repr(C)]
54 #[derive(Clone)]
55 /// Task attributes.
56 pub struct FfrtTaskAttr {
57     storage: [u8; 128],
58 }
59 
60 /// Result returned by the ffrt task.
61 pub type FfrtResult<T> = Result<T, c_int>;
62