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_timerandset_timer_intervalfunctions. Pass toclear_timerto remove the timer.
Functions§
- clear_
timer - Cancels an existing timer. Does nothing if the timer has already been canceled.
- set_
timer - Sets
futureto be executed later, afterdelay. Panics ifdelay+time()is more thanu64::MAXnanoseconds. - set_
timer_ interval - Sets
functo be executed everyinterval. Panics ifinterval+time()is more thanu64::MAXnanoseconds. - set_
timer_ interval_ serial - Sets
functo be executed everyinterval. Panics ifinterval+time()is more thanu64::MAXnanoseconds.