twizzler_abi/thread/
event.rs

1use crate::object::ObjID;
2
3/// Basic structure of an async event sent to a thread queue.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5#[repr(C)]
6pub struct AsyncEvent {
7    /// The sender thread's control ID, or 0 for kernel.
8    pub sender: ObjID,
9    /// Flags for this event.
10    pub flags: AsyncEventFlags,
11    /// API-specific message.
12    pub message: u32,
13    /// API-specific data.
14    pub aux: [u64; MAX_AUX_DATA],
15}
16
17impl AsyncEvent {
18    /// Construct a new AsyncEvent.
19    pub fn new(
20        sender: ObjID,
21        flags: AsyncEventFlags,
22        message: u32,
23        aux: [u64; MAX_AUX_DATA],
24    ) -> Self {
25        Self {
26            sender,
27            flags,
28            message,
29            aux,
30        }
31    }
32}
33
34/// Maximum number of aux data slots.
35pub const MAX_AUX_DATA: usize = 7;
36
37bitflags::bitflags! {
38    /// Async event flags.
39    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
40    pub struct AsyncEventFlags : u32 {
41        /// The sender did not (or does not) want to wait for the completion.
42        const NON_BLOCKING = 1;
43    }
44}
45
46/// The basic structure of an async event completion message.
47#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
48#[repr(C)]
49pub struct AsyncEventCompletion {
50    /// Flags about this completion. Reserved for future use.
51    pub flags: AsyncEventCompletionFlags,
52    /// API-specific status code.
53    pub status: u32,
54    /// API-specific data.
55    pub aux: [u64; MAX_AUX_DATA],
56}
57
58impl AsyncEventCompletion {
59    /// Construct a new AsyncEventCompletion.
60    pub fn new(flags: AsyncEventCompletionFlags, status: u32, aux: [u64; MAX_AUX_DATA]) -> Self {
61        Self { flags, status, aux }
62    }
63}
64
65bitflags::bitflags! {
66    /// Async event completion flags. Reserved for future use.
67    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
68    pub struct AsyncEventCompletionFlags : u32 {
69    }
70}