diff --git a/src/timer.rs b/src/timer.rs index d25cd34..1ace3fe 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -11,11 +11,18 @@ const TVR_MASK: usize = TVR_SIZE - 1; pub type TimerAttacherRp = Rc::>; pub type TimerWp = Weak::>>; -pub type TimerCb = Box::>>)>; +pub type TimerCb = Box::>>)>; type TimerListListHeadRp = Rc::>>; type TimerListRp = Rc::>; type TimerListWp = Weak::>; +pub enum TimerEvent { + Exec, + Delete, + Destory, + Custom(i32) +} + pub struct TimerAttacher { timers: TimerListListHeadRp, } @@ -90,7 +97,7 @@ impl Timer { self.timer_tick = (self.get_tick_count)(); let self_wp = self.shared_from_self(); let cb = Box::new( - move |_event: i32, _args: Option>>| { + move |_event: TimerEvent, _args: Option>>| { self_wp.borrow_mut().gc_timer(_event, _args); } ); @@ -165,7 +172,7 @@ impl Timer { let timer = &self.work_list.borrow().first_entry(); self.running_timer = timer.clone(); match &timer.upgrade().unwrap().borrow_mut().cb { - Some(v) => { + Some(_v) => { //(*v)(0, None); } None => { @@ -271,8 +278,18 @@ impl Timer { return 0; } - fn gc_timer(&mut self, _e: i32, _args: Option>>) { + fn gc_timer(&mut self, e: TimerEvent, _args: Option>>) { + match e { + TimerEvent::Exec => { + } + TimerEvent::Custom(_v) => { + + } + _ => { + + } + } } }