bb_ops/syscalls/sync/gate_dispatch.rs
1//! `GateDispatch` syscall op - generic multi-input synchronization
2//! barrier. Variadic inputs collapse to a single Trigger output that
3//! fires once every input has landed.
4//!
5//! Authors compose downstream ops that need cross-cutting
6//! synchronization on multiple independent producers. The engine's
7//! frontier already gates op dispatch on all-inputs-ready; this op
8//! gives that semantic a name so a single trigger output can fan
9//! into multiple downstream consumers.
10
11use bb_ir::proto::onnx::NodeProto;
12use bb_runtime::atomic::DispatchResult;
13use bb_runtime::bus::OpError;
14use bb_runtime::runtime::RuntimeResourceRef;
15use bb_runtime::slot_value::SlotValue;
16use bb_runtime::syscall::values::TriggerValue;
17
18/// Marker struct for `register_syscall::<GateDispatchOp>`.
19pub struct GateDispatchOp;
20
21/// `(domain, op_type)` registration key.
22pub const DOMAIN: &str = "ai.bytesandbrains.syscall";
23/// Op type name.
24pub const OP_TYPE: &str = "GateDispatch";
25
26/// Invoke fn - emits a `TriggerValue` on the `out` output. The
27/// engine's all-inputs-ready check already guaranteed every input
28/// arrived before this op fired, so the work here is purely
29/// declarative.
30pub fn invoke(
31 _node: &NodeProto,
32 _inputs: &[(&str, &dyn SlotValue)],
33 _ctx: &mut RuntimeResourceRef<'_>,
34) -> Result<DispatchResult, OpError> {
35 Ok(DispatchResult::Immediate(vec![(
36 "out".to_string(),
37 Box::new(TriggerValue),
38 )]))
39}
40
41
42use bb_runtime::registry::OpRegistration as _BbOpsSyscallReg;
43
44inventory::submit! {
45 _BbOpsSyscallReg {
46 domain: DOMAIN,
47 op_type: OP_TYPE,
48 invoke,
49 kind: bb_runtime::registry::RegistrationKind::Syscall,
50 }
51}