1
This commit is contained in:
parent
7e0ba5ccd1
commit
60265ba68d
29
src/timer.rs
29
src/timer.rs
@ -27,7 +27,7 @@ struct TimerList {
|
|||||||
expire_time: i32,
|
expire_time: i32,
|
||||||
expires: i64,
|
expires: i64,
|
||||||
|
|
||||||
//cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
|
cb: Option<fn (i32, Option<Vec<Rc::<dyn Any>>>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Timer {
|
pub struct Timer {
|
||||||
@ -76,7 +76,14 @@ impl Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn new_timer_list(&mut self) -> Rc::<RefCell::<TimerList>> {
|
fn new_timer_list(&mut self) -> Rc::<RefCell::<TimerList>> {
|
||||||
let p = Rc::new(RefCell::new(TimerList{
|
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(),
|
holder: Default::default(),
|
||||||
wp: Default::default(),
|
wp: Default::default(),
|
||||||
timer_entry: Default::default(),
|
timer_entry: Default::default(),
|
||||||
@ -84,8 +91,9 @@ impl Timer {
|
|||||||
timer_type: 0,
|
timer_type: 0,
|
||||||
expire_time: 0,
|
expire_time: 0,
|
||||||
expires: 0,
|
expires: 0,
|
||||||
//cb: Default::default(),
|
cb: None,
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,25 +102,12 @@ impl Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_timeout(&mut self,
|
pub fn set_timeout(&mut self,
|
||||||
expire_time: i32,
|
|
||||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
expire_time: i32,
|
||||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>)) -> TimerWp {
|
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>)) -> TimerWp {
|
||||||
return TimerWp::new();
|
return TimerWp::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_timeout_wp_ex(&mut self,
|
pub fn set_timeout_ex(&mut self,
|
||||||
expire_time: i32,
|
expire_time: i32,
|
||||||
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
|
cb: fn (i32, Option<Vec<Rc::<dyn Any>>>),
|
||||||
attacher: Rc::<RefCell::<TimerAttacher>>) -> TimerWp {
|
attacher: Rc::<RefCell::<TimerAttacher>>) -> TimerWp {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user