esp_wifi/
tasks.rs
use crate::{
compat::timer_compat::TIMERS,
preempt::{task_create, yield_task},
time::systimer_count,
};
pub(crate) fn init_tasks() {
task_create(timer_task, core::ptr::null_mut(), 8192);
}
pub(crate) extern "C" fn timer_task(_param: *mut esp_wifi_sys::c_types::c_void) {
loop {
let current_timestamp = systimer_count();
let to_run = TIMERS.with(|timers| {
let to_run = unsafe { timers.find_next_due(current_timestamp) }?;
to_run.active = to_run.periodic;
if to_run.periodic {
to_run.started = current_timestamp;
}
Some(to_run.callback)
});
if let Some(to_run) = to_run {
trace!("trigger timer....");
to_run.call();
trace!("timer callback called");
} else {
yield_task();
}
}
}