delay fn
This commit is contained in:
@@ -464,6 +464,15 @@ fn register_write_api(engine: &mut Engine, queues: &QueueMap) {
|
||||
}
|
||||
});
|
||||
|
||||
// delay(secs): insert an explicit pause into the queue, merged with any trailing Delay.
|
||||
let q = queues.clone();
|
||||
engine.register_fn("delay", move |ctx: NativeCallContext, secs: f64| {
|
||||
let src = source_of(&ctx);
|
||||
if let Some(queue) = q.borrow().get(&src) {
|
||||
push_delay(queue, secs.max(0.0));
|
||||
}
|
||||
});
|
||||
|
||||
// now(): pop the back of the queue and push it to the front.
|
||||
// Use after a zero-cost action (say, log) to bypass any pending Delay.
|
||||
let q = queues.clone();
|
||||
|
||||
Reference in New Issue
Block a user