1
This commit is contained in:
parent
a599356cff
commit
48c2278461
@ -53,8 +53,7 @@ impl<T> ListHead<T> {
|
|||||||
return self.next.ptr_eq(&self.prev);
|
return self.next.ptr_eq(&self.prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_tail(&self,
|
pub fn add_tail(&self, pnew: &Rc::<RefCell::<Self>>) {
|
||||||
pnew: &Rc::<RefCell::<ListHead<T>>>) {
|
|
||||||
/*
|
/*
|
||||||
let prev = &mut head.borrow_mut().prev;
|
let prev = &mut head.borrow_mut().prev;
|
||||||
let next = Rc::downgrade(head);
|
let next = Rc::downgrade(head);
|
||||||
@ -71,12 +70,12 @@ impl<T> ListHead<T> {
|
|||||||
return self.next.upgrade().unwrap().borrow().data();
|
return self.next.upgrade().unwrap().borrow().data();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn replace_init(head: &Rc::<RefCell::<ListHead<T>>>,
|
pub fn replace_init(&self, pnew: &mut Rc::<RefCell::<Self>>) {
|
||||||
pnew: &mut Rc::<RefCell::<ListHead<T>>>) {
|
/*
|
||||||
pnew.borrow_mut().next = head.borrow_mut().next.clone();
|
pnew.borrow_mut().next = head.borrow_mut().next.clone();
|
||||||
pnew.borrow_mut().next.upgrade().unwrap().borrow_mut().prev = Rc::downgrade(pnew);
|
pnew.borrow_mut().next.upgrade().unwrap().borrow_mut().prev = Rc::downgrade(pnew);
|
||||||
pnew.borrow_mut().prev = head.borrow_mut().prev.clone();
|
pnew.borrow_mut().prev = head.borrow_mut().prev.clone();
|
||||||
head.borrow_mut().init();
|
head.borrow_mut().init();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_each(&self, cb: fn (&Weak::<RefCell::<T>>) -> bool) {
|
pub fn for_each(&self, cb: fn (&Weak::<RefCell::<T>>) -> bool) {
|
||||||
|
12
src/timer.rs
12
src/timer.rs
@ -211,11 +211,7 @@ impl Timer {
|
|||||||
}
|
}
|
||||||
if !tv[index].borrow().empty() {
|
if !tv[index].borrow().empty() {
|
||||||
let mut cascade_list = crate::ListHead::<TimerList>::new_head();
|
let mut cascade_list = crate::ListHead::<TimerList>::new_head();
|
||||||
crate::ListHead::<TimerList>::replace_init
|
tv[index].borrow().replace_init(&mut cascade_list);
|
||||||
(
|
|
||||||
&mut tv[index],
|
|
||||||
&mut cascade_list
|
|
||||||
);
|
|
||||||
while !cascade_list.borrow().empty() {
|
while !cascade_list.borrow().empty() {
|
||||||
let timer = &cascade_list.borrow().first_entry().upgrade().unwrap();
|
let timer = &cascade_list.borrow().first_entry().upgrade().unwrap();
|
||||||
timer.borrow_mut().timer_entry.borrow_mut().del_init();
|
timer.borrow_mut().timer_entry.borrow_mut().del_init();
|
||||||
@ -241,11 +237,7 @@ impl Timer {
|
|||||||
}
|
}
|
||||||
self.timer_tick += 1;
|
self.timer_tick += 1;
|
||||||
|
|
||||||
crate::ListHead::<TimerList>::replace_init
|
self.work_list.borrow().replace_init(&mut self.tv1[index]);
|
||||||
(
|
|
||||||
&mut self.work_list,
|
|
||||||
&mut self.tv1[index]
|
|
||||||
);
|
|
||||||
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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user