byteor_pipeline_kernel/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(missing_docs)]
3#![deny(unreachable_pub, rust_2018_idioms)]
4#![forbid(unsafe_code)]
5
6pub use indexbus_core::WaitStrategy;
12
13pub mod lane;
15pub mod step;
17
18pub use lane::{
19 LaneRx, LaneRxBorrow, LaneRxError, LaneRxSlot, LaneRxSlotBatch, LaneSlot, LaneTx, LaneTxError,
20 LaneTxSlot, LaneTxSlotError, LaneTxWith, LaneTxWithError, LaneTxWithResult,
21};
22pub use step::{
23 publish_slot_with_policy_or_copy, publish_with_policy, recv_map_ok_publish_with_step,
24 recv_select_publish_batch, recv_select_publish_step,
25 recv_slot_filter_forward_publish_slot_step, recv_slot_forward_publish_slot_step,
26 recv_slot_inspect_forward_publish_slot_step, recv_slot_transform_forward_publish_slot_step,
27 recv_transform_publish_batch, recv_transform_publish_step, recv_with_forward_publish_with_step,
28 recv_with_map_ok_publish_with_step, recv_with_map_publish_with_result_step,
29 recv_with_transform_publish_batch, recv_with_transform_publish_step, TransformOutcome,
30};
31
32pub type Seq = u64;
34
35#[inline]
40pub fn ring_index(seq: Seq, capacity: u64) -> usize {
41 (seq % capacity) as usize
43}
44
45pub trait SeqBarrier {
50 fn available(&self) -> Seq;
52
53 #[inline]
55 fn wait_for<W: WaitStrategy>(&self, seq: Seq, wait: &mut W) -> Seq {
56 loop {
57 let avail = self.available();
58 if avail >= seq {
59 return avail;
60 }
61 wait.wait();
62 }
63 }
64}