From b246bd745ad536cfbb1055ad61afbaf1b0843b6a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 7 Oct 2023 20:58:22 +0800 Subject: [PATCH] 1 --- src/listhead.rs | 14 ++++++++++++-- src/timer.rs | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/listhead.rs b/src/listhead.rs index 0cac040..58e9d0b 100644 --- a/src/listhead.rs +++ b/src/listhead.rs @@ -9,11 +9,21 @@ pub struct ListHead { impl ListHead { - pub fn new() -> Rc::>> { + pub fn new_head() -> Rc::>> { let this = Rc::new(RefCell::new(ListHead{ prev: Weak::>>::new(), next: Weak::>>::new(), - data: Weak::>::new(), + data: Weak::>::new() + })); + this.borrow_mut().init(); + return this; + } + + pub fn new_node(data: Weak::>) -> Rc::>> { + let this = Rc::new(RefCell::new(ListHead{ + prev: Weak::>>::new(), + next: Weak::>>::new(), + data: data })); this.borrow_mut().init(); return this; diff --git a/src/timer.rs b/src/timer.rs index 15b1bc3..dee57c9 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -33,7 +33,21 @@ impl Timer { get_tick_count: fn () -> i64, gctime: i32, cache_timer_num: i32) { - + for i in 0..self.tv1.len() { + self.tv1[i] = crate::ListHead::::new_head(); + } + for i in 0..self.tv2.len() { + self.tv2[i] = crate::ListHead::::new_head(); + } + for i in 0..self.tv3.len() { + self.tv3[i] = crate::ListHead::::new_head(); + } + for i in 0..self.tv4.len() { + self.tv4[i] = crate::ListHead::::new_head(); + } + for i in 0..self.tv5.len() { + self.tv5[i] = crate::ListHead::::new_head(); + } } pub fn uninit(&mut self) {