This commit is contained in:
aozhiwei 2023-10-09 10:42:14 +08:00
parent 28274dd028
commit 7cee6d5f61

View File

@ -31,7 +31,7 @@ impl Default for TimerType {
}
#[derive(Default)]
pub struct TimerList {
struct TimerList {
holder: Rc::<RefCell::<TimerList>>,
wp: Rc::<Rc::<RefCell::<TimerList>>>,
timer_entry: Rc::<RefCell::<crate::ListHead<TimerList>>>,
@ -89,12 +89,12 @@ impl Timer {
}
fn new_timer_list(&mut self) -> Rc::<RefCell::<TimerList>> {
let p: Rc::<RefCell::<TimerList>>;
p = self.free_timer_list.borrow().first_entry().upgrade().unwrap();
if Rc::weak_count(&p.borrow().wp) > 0 {
p.borrow_mut().wp = Rc::new(p.borrow().holder.clone());
}
let mut p: Rc::<RefCell::<TimerList>>;
if self.free_timer_list.borrow().empty() {
p = self.free_timer_list.borrow().first_entry().upgrade().unwrap();
if Rc::weak_count(&p.borrow().wp) > 0 {
p.borrow_mut().wp = Rc::new(p.borrow().holder.clone());
}
} else {
p = Rc::new(RefCell::new(TimerList{
holder: Default::default(),