This commit is contained in:
aozhiwei 2023-10-29 12:12:41 +08:00
parent 2fb1fe39d0
commit b3b1cf49f8
2 changed files with 7 additions and 16 deletions

View File

@ -101,8 +101,8 @@ impl<T> ListHead<T> {
pub fn replace_init(head: &Rc::<RefCell::<Self>>, pnew: &Rc::<RefCell::<Self>>) { pub fn replace_init(head: &Rc::<RefCell::<Self>>, pnew: &Rc::<RefCell::<Self>>) {
if !head.borrow().empty() { if !head.borrow().empty() {
let timer = &head.borrow().first_entry(); //let timer = &head.borrow().first_entry();
let a = timer.upgrade().unwrap(); //let a = timer.upgrade().unwrap();
} else { } else {
return; return;
} }
@ -113,8 +113,8 @@ impl<T> ListHead<T> {
pnew.borrow_mut().prev.upgrade().unwrap().borrow_mut().next = Rc::downgrade(pnew); pnew.borrow_mut().prev.upgrade().unwrap().borrow_mut().next = Rc::downgrade(pnew);
head.borrow_mut().init(); head.borrow_mut().init();
if !pnew.borrow().empty() { if !pnew.borrow().empty() {
let timer = &pnew.borrow().first_entry(); //let timer = &pnew.borrow().first_entry();
let a = timer.upgrade().unwrap(); //let a = timer.upgrade().unwrap();
} }
} }

View File

@ -227,7 +227,7 @@ impl XTimer {
} }
println!("zzzzzzz idx:{} index:{}", idx, index); println!("zzzzzzz idx:{} index:{}", idx, index);
if !tv[index].borrow().empty() { if !tv[index].borrow().empty() {
let mut cascade_list = crate::ListHead::<TimerList>::new_head(); let cascade_list = crate::ListHead::<TimerList>::new_head();
crate::ListHead::<TimerList>::replace_init crate::ListHead::<TimerList>::replace_init
(&tv[index], (&tv[index],
&cascade_list); &cascade_list);
@ -245,15 +245,7 @@ impl XTimer {
} }
pub fn update(&mut self) { pub fn update(&mut self) {
let mut tick = 0; let tick = (*self.get_tick_count.as_ref().unwrap())();
match &self.get_tick_count {
Some(v) => {
tick = (*v)();
}
None => {
}
}
while tick >= self.timer_tick { while tick >= self.timer_tick {
let index = (self.timer_tick & (TVR_MASK as i64)) as usize; let index = (self.timer_tick & (TVR_MASK as i64)) as usize;
if index == 0 && if index == 0 &&
@ -263,7 +255,6 @@ impl XTimer {
self.cascade(3); self.cascade(3);
} }
self.timer_tick += 1; self.timer_tick += 1;
println!("wwwwwwwwwwww");
//println!("timer_tick:{} index:{} empty:{}", self.timer_tick, index, self.tv1[index].borrow().empty()); //println!("timer_tick:{} index:{} empty:{}", self.timer_tick, index, self.tv1[index].borrow().empty());
crate::ListHead::<TimerList>::replace_init crate::ListHead::<TimerList>::replace_init
@ -272,7 +263,7 @@ impl XTimer {
while !self.work_list.borrow().empty() { while !self.work_list.borrow().empty() {
let timer = &self.work_list.borrow().first_entry(); let timer = &self.work_list.borrow().first_entry();
self.running_timer = timer.clone(); self.running_timer = timer.clone();
let a = timer.upgrade().unwrap(); //let a = timer.upgrade().unwrap();
match &mut timer.upgrade().unwrap().borrow_mut().cb { match &mut timer.upgrade().unwrap().borrow_mut().cb {
Some(v) => { Some(v) => {
(*v)(TimerEvent::Exec, None); (*v)(TimerEvent::Exec, None);