This commit is contained in:
aozhiwei 2023-10-07 23:16:08 +08:00
parent c7dae045be
commit 7e0ba5ccd1
2 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,7 @@
use std::rc::{Rc, Weak};
use std::cell::RefCell;
#[derive(Default)]
pub struct ListHead<T> {
prev: Weak::<RefCell::<ListHead<T>>>,
next: Weak::<RefCell::<ListHead<T>>>,

View File

@ -12,10 +12,12 @@ const TVR_MASK: usize = TVR_SIZE - 1;
pub type TimerWp = Weak::<Rc::<RefCell::<TimerList>>>;
#[derive(Default)]
pub struct TimerAttacher {
timers: Rc::<RefCell::<crate::ListHead<TimerAttacher>>>,
}
#[derive(Default)]
struct TimerList {
holder: Rc::<RefCell::<TimerList>>,
wp: Rc::<Rc::<RefCell::<TimerList>>>,
@ -25,7 +27,7 @@ struct TimerList {
expire_time: i32,
expires: i64,
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
//cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
}
pub struct Timer {
@ -73,6 +75,20 @@ impl Timer {
}
fn new_timer_list(&mut self) -> Rc::<RefCell::<TimerList>> {
let p = Rc::new(RefCell::new(TimerList{
holder: Default::default(),
wp: Default::default(),
timer_entry: Default::default(),
attach_entry: Default::default(),
timer_type: 0,
expire_time: 0,
expires: 0,
//cb: Default::default(),
}));
return p;
}
pub fn update(&mut self) {
}