bb_ops/syscalls/triggers/
after.rs1use bb_ir::proto::onnx::NodeProto;
8use bb_runtime::atomic::DispatchResult;
9use bb_runtime::bus::OpError;
10use bb_runtime::framework::TimerKind;
11use bb_runtime::runtime::RuntimeResourceRef;
12use bb_runtime::slot_value::SlotValue;
13
14pub struct AfterOp;
16
17pub const DOMAIN: &str = "ai.bytesandbrains.syscall";
19pub const OP_TYPE: &str = "After";
21
22pub fn invoke(
24 node: &NodeProto,
25 _inputs: &[(&str, &dyn SlotValue)],
26 ctx: &mut RuntimeResourceRef<'_>,
27) -> Result<DispatchResult, OpError> {
28 let delay_ns = node
29 .attribute
30 .iter()
31 .find(|a| a.name == "delay_ns")
32 .map(|a| a.i as u64)
33 .unwrap_or(0);
34 let now = ctx.time.scheduler.now_ns();
35 let cmd = ctx.allocate_command_id();
36 ctx.time.scheduler.schedule(
37 now.saturating_add(delay_ns),
38 TimerKind::After { key: cmd.as_u64() },
39 );
40 Ok(DispatchResult::Async(cmd))
41}
42
43use bb_runtime::registry::OpRegistration as _BbOpsSyscallReg;
44
45inventory::submit! {
46 _BbOpsSyscallReg {
47 domain: DOMAIN,
48 op_type: OP_TYPE,
49 invoke,
50 kind: bb_runtime::registry::RegistrationKind::Syscall,
51 }
52}