indexbus_abi/layouts/
wake.rs

1use crate::{IndexbusAtomicU32, LayoutHeader};
2
3/// WakeCell is a 64-byte, 64-aligned monotonic counter.
4///
5/// It is appended to layouts when `INDEXBUS_CAP_SUPPORTS_BLOCKING` is set.
6#[repr(C, align(64))]
7pub struct WakeCell {
8    /// Monotonic sequence value used for wait/wake.
9    pub seq: IndexbusAtomicU32,
10    /// Padding (reserved).
11    pub pad0: u32,
12    /// Padding to 64 bytes.
13    pub pad_to_64: [u8; 56],
14}
15
16#[allow(dead_code)]
17const _WAKE_CELL_SIZE_CHECK: [u8; 64] = [0u8; core::mem::size_of::<WakeCell>()];
18
19/// Optional appended wake section for `SharedLayout`.
20#[repr(C, align(64))]
21pub struct SharedWakeSection {
22    /// Wake cell for the SPSC queue.
23    pub spsc_wake: WakeCell,
24    /// Wake cell for the MPSC queue.
25    pub mpsc_wake: WakeCell,
26}
27
28#[allow(dead_code)]
29const _SHARED_WAKE_SECTION_SIZE_CHECK: [u8; 128] = [0u8; core::mem::size_of::<SharedWakeSection>()];
30
31/// Optional appended wake section for a state region.
32#[repr(C, align(64))]
33pub struct StateWakeSection {
34    /// Wake cell for state updates.
35    pub state_wake: WakeCell,
36}
37
38#[allow(dead_code)]
39const _STATE_WAKE_SECTION_SIZE_CHECK: [u8; 64] = [0u8; core::mem::size_of::<StateWakeSection>()];
40
41/// Optional appended wake section for a fanout region.
42#[repr(C, align(64))]
43pub struct FanoutWakeSection<const N: usize> {
44    /// Wake cell for the producer cursor.
45    pub producer_wake: WakeCell,
46    /// Per-consumer wake cells.
47    pub consumer_wake: [WakeCell; N],
48}
49
50/// Concrete v1 fanout wake section for `N=4`.
51#[repr(C, align(64))]
52pub struct FanoutWakeSection4 {
53    /// Wake cell for the producer cursor.
54    pub producer_wake: WakeCell,
55    /// Per-consumer wake cells.
56    pub consumer_wake: [WakeCell; 4],
57}
58
59/// Optional appended wake section for a sequencer region.
60#[repr(C, align(64))]
61pub struct SequencerWakeSection<const N: usize> {
62    /// Wake cell for the producer cursor.
63    pub producer_wake: WakeCell,
64    /// Per-consumer wake cells.
65    pub consumer_wake: [WakeCell; N],
66}
67
68/// Concrete v1 sequencer wake section for `N=4`.
69#[repr(C, align(64))]
70pub struct SequencerWakeSection4 {
71    /// Wake cell for the producer cursor.
72    pub producer_wake: WakeCell,
73    /// Per-consumer wake cells.
74    pub consumer_wake: [WakeCell; 4],
75}
76
77/// Optional appended wake section for a journal region.
78///
79/// (Concrete v1 shape: 1 publisher + 4 subscribers.)
80#[repr(C, align(64))]
81pub struct JournalWakeSection4 {
82    /// Wake cell for the publisher.
83    pub publisher_wake: WakeCell,
84    /// Per-subscriber wake cells.
85    pub subscriber_wake: [WakeCell; 4],
86}
87
88// This import is intentionally kept to make it clear wake sections are append-only.
89#[allow(unused_imports)]
90use LayoutHeader as _;