From a69795e9ddc1dffa13eb0184d53a47ab13a73437 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 28 Oct 2023 20:33:06 +0800 Subject: [PATCH] 1 --- src/xtimer.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/xtimer.rs b/src/xtimer.rs index ae4d83f..8cf2467 100644 --- a/src/xtimer.rs +++ b/src/xtimer.rs @@ -66,18 +66,16 @@ pub struct XTimer { get_tick_count: Option i64>>, cache_timer_num: i32, work_list: TimerListListHeadRp, - tv0: [Option; TVR_SIZE], - tv1: [TimerListListHeadRp; TVR_SIZE], - tv2: [TimerListListHeadRp; TVN_SIZE], - tv3: [TimerListListHeadRp; TVN_SIZE], - tv4: [TimerListListHeadRp; TVN_SIZE], - tv5: [TimerListListHeadRp; TVN_SIZE], + tv1: Vec, + tv2: Vec, + tv3: Vec, + tv4: Vec, + tv5: Vec, _self_wp: Weak::>, } impl XTimer { - /* pub fn new() -> Rc::> { let t: TimerListListHeadRp = Default::default(); let this = Rc::new(RefCell::new(XTimer{ @@ -88,17 +86,16 @@ impl XTimer { get_tick_count: Default::default(), cache_timer_num: 0, work_list: Default::default(), - tv0: [None; TVR_SIZE], - tv1: [t.clone(); TVR_SIZE], - tv2: [Default::default(); TVN_SIZE], - tv3: [Default::default(); TVN_SIZE], - tv4: [Default::default(); TVN_SIZE], - tv5: [Default::default(); TVN_SIZE], + tv1: Vec::with_capacity(TVR_SIZE), + tv2: Vec::with_capacity(TVN_SIZE), + tv3: Vec::with_capacity(TVN_SIZE), + tv4: Vec::with_capacity(TVN_SIZE), + tv5: Vec::with_capacity(TVN_SIZE), _self_wp: Default::default(), })); this.borrow_mut()._self_wp = Rc::downgrade(&this); return this; - }*/ + } pub fn init(&mut self, get_tick_count: Box i64>, @@ -116,7 +113,6 @@ impl XTimer { self.timer_tick = (*v)(); } None => { - } } {