This commit is contained in:
aozhiwei 2023-10-07 20:58:22 +08:00
parent 3247ff5f40
commit b246bd745a
2 changed files with 27 additions and 3 deletions

View File

@ -9,11 +9,21 @@ pub struct ListHead<T> {
impl<T> ListHead<T> {
pub fn new() -> Rc::<RefCell::<ListHead<T>>> {
pub fn new_head() -> Rc::<RefCell::<ListHead<T>>> {
let this = Rc::new(RefCell::new(ListHead{
prev: Weak::<RefCell::<ListHead<T>>>::new(),
next: Weak::<RefCell::<ListHead<T>>>::new(),
data: Weak::<RefCell::<T>>::new(),
data: Weak::<RefCell::<T>>::new()
}));
this.borrow_mut().init();
return this;
}
pub fn new_node(data: Weak::<RefCell::<T>>) -> Rc::<RefCell::<ListHead<T>>> {
let this = Rc::new(RefCell::new(ListHead{
prev: Weak::<RefCell::<ListHead<T>>>::new(),
next: Weak::<RefCell::<ListHead<T>>>::new(),
data: data
}));
this.borrow_mut().init();
return this;

View File

@ -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::<TimerList>::new_head();
}
for i in 0..self.tv2.len() {
self.tv2[i] = crate::ListHead::<TimerList>::new_head();
}
for i in 0..self.tv3.len() {
self.tv3[i] = crate::ListHead::<TimerList>::new_head();
}
for i in 0..self.tv4.len() {
self.tv4[i] = crate::ListHead::<TimerList>::new_head();
}
for i in 0..self.tv5.len() {
self.tv5[i] = crate::ListHead::<TimerList>::new_head();
}
}
pub fn uninit(&mut self) {