From 1709853ee59e91ef572cd75c12e90967fa8b6b23 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 10 Oct 2023 08:50:18 +0800 Subject: [PATCH] 1 --- src/timer.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/timer.rs b/src/timer.rs index 9b971cc..e5cf36b 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -83,7 +83,7 @@ impl Timer { } self.timer_tick = (self.get_tick_count)(); let cb = Rc::new( - |e: i32, args: Option>>| { + |_event: i32, _args: Option>>| { //self.gc_timer(e, args); } ); @@ -98,7 +98,7 @@ impl Timer { } - fn clear(&mut self, cb: Option>>)>>) { + fn clear(&mut self) { } @@ -155,6 +155,20 @@ impl Timer { } { let idx = t.borrow().expires - self.timer_tick; + let mut index = 0; + let vec: &mut Rc::>>; + if idx < 0 { + index = self.timer_tick & (TVR_MASK as i64); + vec = &mut self.tv1[index as usize]; + } else if idx < TVR_SIZE as i64 { + index = t.borrow().expires & (TVR_MASK as i64); + vec = &mut self.tv1[index as usize]; + } else { + index = t.borrow().expires & (TVR_MASK as i64); + vec = &mut self.tv1[index as usize]; + } + crate::ListHead::add_tail(&vec, + &t.borrow_mut().timer_entry); } return Rc::downgrade(&t.borrow().wp); }