bb_ops/syscalls/clock_rng/
deadline_match.rs1use bb_ir::proto::onnx::NodeProto;
5use bb_runtime::atomic::DispatchResult;
6use bb_runtime::bus::OpError;
7use bb_runtime::runtime::RuntimeResourceRef;
8use bb_runtime::slot_value::SlotValue;
9use bb_runtime::syscall::values::TriggerValue;
10
11pub struct DeadlineMatchOp;
13
14pub const DOMAIN: &str = "ai.bytesandbrains.syscall";
16pub const OP_TYPE: &str = "DeadlineMatch";
18
19pub fn invoke(
25 _node: &NodeProto,
26 inputs: &[(&str, &dyn SlotValue)],
27 ctx: &mut RuntimeResourceRef<'_>,
28) -> Result<DispatchResult, OpError> {
29 if inputs.is_empty() {
30 return Err(OpError {
31 detail: "DeadlineMatch requires at least one input".to_string(),
32 ..Default::default()
33 });
34 }
35 let latch_key = (ctx.current.op_ref.as_u64(), ctx.current.exec_id.as_u64());
39 if !ctx.syscall.deadline_match_fired.insert(latch_key) {
40 return Ok(DispatchResult::Immediate(vec![]));
41 }
42 Ok(DispatchResult::Immediate(vec![(
43 "winner".to_string(),
44 Box::new(TriggerValue),
45 )]))
46}
47
48use bb_runtime::registry::OpRegistration as _BbOpsSyscallReg;
49
50inventory::submit! {
51 _BbOpsSyscallReg {
52 domain: DOMAIN,
53 op_type: OP_TYPE,
54 invoke,
55 kind: bb_runtime::registry::RegistrationKind::Syscall,
56 }
57}