This commit is contained in:
aozhiwei 2023-10-24 09:02:27 +08:00
parent 873e104469
commit a1589b9773
2 changed files with 25 additions and 3 deletions

View File

@ -77,7 +77,7 @@ impl<T> ListHead<T> {
return self.next.upgrade().unwrap().borrow().data();
}
pub fn replace_init(head: &mut Rc::<RefCell::<ListHead<T>>>,
pub fn replace_init(head: &Rc::<RefCell::<ListHead<T>>>,
pnew: &mut Rc::<RefCell::<ListHead<T>>>) {
pnew.borrow_mut().next = head.borrow_mut().next.clone();
pnew.borrow_mut().next.upgrade().unwrap().borrow_mut().prev = Rc::downgrade(pnew);

View File

@ -167,7 +167,26 @@ impl Timer {
return p;
}
fn cascade(&mut self, tv: &mut [TimerListListHeadRp], index: usize) -> usize {
fn cascade(&mut self, idx: usize) -> usize {
let index = self.get_timer_index(idx);
let tv : &mut [TimerListListHeadRp];
match idx {
0 => {
tv = &mut self.tv2;
}
1 => {
tv = &mut self.tv3;
}
2 => {
tv = &mut self.tv4;
}
3 => {
tv = &mut self.tv5;
}
_ => {
tv = &mut self.tv5;
}
}
if !tv[index].borrow().empty() {
let mut cascade_list = crate::ListHead::<TimerList>::new_head();
crate::ListHead::<TimerList>::replace_init
@ -194,7 +213,10 @@ impl Timer {
while tick >= self.timer_tick {
let index = (self.timer_tick & (TVR_MASK as i64)) as usize;
if index == 0 &&
self.cascade(&mut self.tv2, self.get_timer_index(0)) == 0 {
self.cascade(0) == 0 &&
self.cascade(1) == 0 &&
self.cascade(2) == 0 {
self.cascade(3);
}
self.timer_tick += 1;