bb_ops/syscalls/clock_rng/
clock.rs1use bb_ir::proto::onnx::NodeProto;
4use bb_runtime::atomic::DispatchResult;
5use bb_runtime::bus::OpError;
6use bb_runtime::runtime::RuntimeResourceRef;
7use bb_runtime::slot_value::SlotValue;
8use bb_runtime::syscall::values::TimestampValue;
9
10pub struct ClockOp;
12
13pub const DOMAIN: &str = "ai.bytesandbrains.syscall";
15pub const OP_TYPE: &str = "Clock";
17
18pub fn invoke(
20 _node: &NodeProto,
21 _inputs: &[(&str, &dyn SlotValue)],
22 ctx: &mut RuntimeResourceRef<'_>,
23) -> Result<DispatchResult, OpError> {
24 let now_ns = ctx.time.scheduler.now_ns();
25 Ok(DispatchResult::Immediate(vec![(
26 "now".to_string(),
27 Box::new(TimestampValue(now_ns)),
28 )]))
29}
30
31use bb_runtime::registry::OpRegistration as _BbOpsSyscallReg;
32
33inventory::submit! {
34 _BbOpsSyscallReg {
35 domain: DOMAIN,
36 op_type: OP_TYPE,
37 invoke,
38 kind: bb_runtime::registry::RegistrationKind::Syscall,
39 }
40}