1
This commit is contained in:
parent
7e0ba5ccd1
commit
60265ba68d
49
src/timer.rs
49
src/timer.rs
@ -27,7 +27,7 @@ struct TimerList {
|
||||
expire_time: i32,
|
||||
expires: i64,
|
||||
|
||||
//cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
|
||||
cb: Option<fn (i32, Option<Vec<Rc::<dyn Any>>>)>,
|
||||
}
|
||||
|
||||
pub struct Timer {
|
||||
@ -76,16 +76,24 @@ 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(),
|
||||
}));
|
||||
let mut p: Rc::<RefCell::<TimerList>>;
|
||||
if self.free_timer_list.borrow().empty() {
|
||||
p = self.free_timer_list.borrow().first_entry().upgrade().unwrap();
|
||||
if Rc::weak_count(&p.borrow().wp) > 0 {
|
||||
p.borrow_mut().wp = Rc::new(p.borrow().holder.clone());
|
||||
}
|
||||
} else {
|
||||
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: None,
|
||||
}));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -95,27 +103,14 @@ impl Timer {
|
||||
|
||||
pub fn set_timeout(&mut self,
|
||||
expire_time: i32,
|
||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>)) {
|
||||
|
||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>)) -> TimerWp {
|
||||
return TimerWp::new();
|
||||
}
|
||||
|
||||
pub fn set_timeout_ex(&mut self,
|
||||
expire_time: i32,
|
||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
|
||||
attacher: Rc::<RefCell::<TimerAttacher>>) {
|
||||
|
||||
}
|
||||
|
||||
pub fn set_timeout_wp(&mut self,
|
||||
expire_time: i32,
|
||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>)) -> TimerWp {
|
||||
return TimerWp::new();
|
||||
}
|
||||
|
||||
pub fn set_timeout_wp_ex(&mut self,
|
||||
expire_time: i32,
|
||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
|
||||
attacher: Rc::<RefCell::<TimerAttacher>>) -> TimerWp {
|
||||
attacher: Rc::<RefCell::<TimerAttacher>>) -> TimerWp {
|
||||
return TimerWp::new();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user