Skip to main content

schedule_relative

Macro schedule_relative 

Source
macro_rules! schedule_relative {
    ($context:expr, $delay:expr, $action:expr $(, $arg:expr)* $(,)?) => { ... };
}
Expand description

Schedules an action after a delay relative to the context’s current time.

The scheduled action is called with the executing context: &mut Context as its first argument, followed by each remaining macro argument in the same order.

For example:

schedule_relative!(context, my_delay, my_handler, arg1, arg2, arg3);

expands to code like:

{
    let time = context.get_current_time() + my_delay;
    context.add_plan(time, move |context| {
        my_handler(context, arg1, arg2, arg3)
    })
}