• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 deadline;
18 mod sys_event;
19 mod task;
20 
21 pub use config::*;
22 pub use deadline::*;
23 use libc::{c_int, c_void};
24 pub use sys_event::*;
25 pub use task::*;
26 pub use {ffrt_get_current_task, ffrt_submit_coroutine};
27 
28 #[repr(C)]
29 #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
30 /// Qos levels.
31 pub enum Qos {
32     /// Inherits parent's qos level
33     Inherent = -1,
34     /// Lowest qos
35     Background,
36     /// Utility qos
37     Utility,
38     /// Default qos
39     Default,
40     /// User initialiated qos
41     UserInitiated,
42     /// Deadline qos
43     DeadlineRequest,
44     /// Highest qos
45     UserInteractive,
46 }
47 
48 #[repr(C)]
49 /// Dependencies for the task.
50 pub struct FfrtDeps {
51     len: u32,
52     items: *const *const c_void,
53 }
54 
55 #[repr(C)]
56 #[derive(Clone)]
57 /// Task attributes.
58 pub struct FfrtTaskAttr {
59     storage: [u8; 128],
60 }
61 
62 /// Result returned by the ffrt task.
63 pub type FfrtResult<T> = Result<T, c_int>;
64