1
This commit is contained in:
parent
30c02c0c0c
commit
a8535d4da8
25
src/timer.rs
25
src/timer.rs
@ -11,11 +11,18 @@ const TVR_MASK: usize = TVR_SIZE - 1;
|
||||
|
||||
pub type TimerAttacherRp = Rc::<RefCell::<TimerAttacher>>;
|
||||
pub type TimerWp = Weak::<Rc::<RefCell::<TimerList>>>;
|
||||
pub type TimerCb = Box::<dyn FnMut (i32, Option<Vec<Rc::<dyn Any>>>)>;
|
||||
pub type TimerCb = Box::<dyn FnMut (TimerEvent, Option<Vec<Rc::<dyn Any>>>)>;
|
||||
type TimerListListHeadRp = Rc::<RefCell::<crate::ListHead<TimerList>>>;
|
||||
type TimerListRp = Rc::<RefCell::<TimerList>>;
|
||||
type TimerListWp = Weak::<RefCell::<TimerList>>;
|
||||
|
||||
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<Vec<Rc::<dyn Any>>>| {
|
||||
move |_event: TimerEvent, _args: Option<Vec<Rc::<dyn Any>>>| {
|
||||
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<Vec<Rc::<dyn Any>>>) {
|
||||
fn gc_timer(&mut self, e: TimerEvent, _args: Option<Vec<Rc::<dyn Any>>>) {
|
||||
match e {
|
||||
TimerEvent::Exec => {
|
||||
|
||||
}
|
||||
TimerEvent::Custom(_v) => {
|
||||
|
||||
}
|
||||
_ => {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user