This commit is contained in:
aozhiwei 2023-10-29 12:52:39 +08:00
parent b3b1cf49f8
commit e04edb26a8

View File

@ -244,6 +244,45 @@ impl XTimer {
return ((self.timer_tick as usize) >> (TVR_BITS + index * TVN_BITS)) & TVN_MASK;
}
fn fetch_work_list(&self, tick: i64) -> bool {
return true;
}
pub fn update(this: &Rc::<RefCell::<XTimer>>) {
let tick = (*this.borrow().get_tick_count.as_ref().unwrap())();
let work_list = this.borrow().work_list.clone();
while this.borrow().fetch_work_list(tick) {
while !work_list.borrow().empty() {
let timer = &work_list.borrow().first_entry();
this.borrow_mut().running_timer = timer.clone();
match &mut timer.upgrade().unwrap().borrow_mut().cb {
Some(v) => {
(*v)(TimerEvent::Exec, None);
}
None => {
}
}
match this.borrow().running_timer.upgrade() {
Some(v) => {
match v.borrow().timer_type {
TimerType::Timeout => {
this.borrow_mut().internal_delete(Rc::downgrade(&v.borrow().wp.clone().unwrap()), false);
}
TimerType::Interval => {
this.borrow_mut().modify(Rc::downgrade(&v.borrow().wp.clone().unwrap()),
v.borrow().expire_time);
}
}
}
None => {
}
}
}
}
this.borrow_mut().running_timer = Weak::new();
}
/*
pub fn update(&mut self) {
let tick = (*self.get_tick_count.as_ref().unwrap())();
while tick >= self.timer_tick {
@ -290,7 +329,7 @@ impl XTimer {
}
}
self.running_timer = Weak::new();
}
}*/
fn internal_add(&mut self,
timer_type: TimerType,