This commit is contained in:
aozhiwei 2023-10-19 22:22:15 +08:00
parent 746fe5b87c
commit 30fc9dcc0a

View File

@ -78,11 +78,10 @@ impl Timer {
self.get_tick_count = get_tick_count;
self.cache_timer_num = cache_timer_num;
self.free_timer_num = 0;
self.work_list = crate::ListHead::<TimerList>::new_head();
/*self.traverse_timer_list(
self.traverse_timer_list(
&mut |timer_list: &mut TimerListListHeadRp| {
timer_list = crate::ListHead::<TimerList>::new_head();
});*/
*timer_list = crate::ListHead::<TimerList>::new_head();
});
self.timer_tick = (self.get_tick_count)();
{
let self_wp = self.shared_from_self();
@ -95,27 +94,18 @@ impl Timer {
}
}
fn traverse_timer_list(&mut self, cb: Box::<dyn FnMut (&mut TimerListListHeadRp)>) {
let init_timer_list = |tv: &mut [TimerListListHeadRp]| {
fn traverse_timer_list(&mut self, cb: &mut dyn FnMut (&mut TimerListListHeadRp)) {
(*cb)(&mut self.work_list);
let mut init_timer_list = |tv: &mut [TimerListListHeadRp]| {
for i in 0..tv.len() {
//(*cb)(&mut self.work_list);
//(*cb)(&mut tv[i]);
(*cb)(&mut tv[i]);
}
};
(*cb)(&mut self.work_list);
/*
match &mut cb {
Some(v) => {
(*v)(&mut self.work_list);
}
None => {
}
}*/
//init_timer_list(&mut self.tv1);
/*init_timer_list(&mut self.tv2);
init_timer_list(&mut self.tv1);
init_timer_list(&mut self.tv2);
init_timer_list(&mut self.tv3);
init_timer_list(&mut self.tv4);
init_timer_list(&mut self.tv5);*/
init_timer_list(&mut self.tv5);
}
fn shared_from_self(&self) -> Rc::<RefCell::<Timer>> {