Crate ic_cdk_timers

Crate ic_cdk_timers 

Source
Expand description

This library implements multiple and periodic timers on the Internet Computer.

§Example

ic_cdk_timers::set_timer(Duration::from_secs(1), async { ic_cdk::println!("Hello from the future!") });

§Details

Timers internally use a bounded-wait self-call for error handling purposes. This is not guaranteed to remain the case in the future, but means that if the system is under heavy load, timers may begin to slow down by a lot as the self-calls begin to time out and the timers are rescheduled for the next global timer tick. This also means that each executed timer incurs the cycle cost of a canister call.

Timers are not persisted across canister upgrades.

Structs§

TimerId
Type returned by the set_timer and set_timer_interval functions. Pass to clear_timer to remove the timer.

Functions§

clear_timer
Cancels an existing timer. Does nothing if the timer has already been canceled.
set_timer
Sets future to be executed later, after delay. Panics if delay + time() is more than u64::MAX nanoseconds.
set_timer_interval
Sets func to be executed every interval. Panics if interval + time() is more than u64::MAX nanoseconds.
set_timer_interval_serial
Sets func to be executed every interval. Panics if interval + time() is more than u64::MAX nanoseconds.