1
This commit is contained in:
parent
e04edb26a8
commit
c8ea47bcc8
@ -244,14 +244,31 @@ impl XTimer {
|
|||||||
return ((self.timer_tick as usize) >> (TVR_BITS + index * TVN_BITS)) & TVN_MASK;
|
return ((self.timer_tick as usize) >> (TVR_BITS + index * TVN_BITS)) & TVN_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_work_list(&self, tick: i64) -> bool {
|
fn fetch_work_list(&mut self, tick: i64) -> bool {
|
||||||
return true;
|
if tick >= self.timer_tick {
|
||||||
|
let index = (self.timer_tick & (TVR_MASK as i64)) as usize;
|
||||||
|
if index == 0 &&
|
||||||
|
self.cascade(0) == 0 &&
|
||||||
|
self.cascade(1) == 0 &&
|
||||||
|
self.cascade(2) == 0 {
|
||||||
|
self.cascade(3);
|
||||||
|
}
|
||||||
|
self.timer_tick += 1;
|
||||||
|
|
||||||
|
//println!("timer_tick:{} index:{} empty:{}", self.timer_tick, index, self.tv1[index].borrow().empty());
|
||||||
|
crate::ListHead::<TimerList>::replace_init
|
||||||
|
(&self.tv1[index],
|
||||||
|
&self.work_list);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(this: &Rc::<RefCell::<XTimer>>) {
|
pub fn update(this: &Rc::<RefCell::<XTimer>>) {
|
||||||
let tick = (*this.borrow().get_tick_count.as_ref().unwrap())();
|
let tick = (*this.borrow().get_tick_count.as_ref().unwrap())();
|
||||||
let work_list = this.borrow().work_list.clone();
|
let work_list = this.borrow().work_list.clone();
|
||||||
while this.borrow().fetch_work_list(tick) {
|
while this.borrow_mut().fetch_work_list(tick) {
|
||||||
while !work_list.borrow().empty() {
|
while !work_list.borrow().empty() {
|
||||||
let timer = &work_list.borrow().first_entry();
|
let timer = &work_list.borrow().first_entry();
|
||||||
this.borrow_mut().running_timer = timer.clone();
|
this.borrow_mut().running_timer = timer.clone();
|
||||||
@ -262,7 +279,8 @@ impl XTimer {
|
|||||||
None => {
|
None => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match this.borrow().running_timer.upgrade() {
|
let running_timer = this.borrow().running_timer.clone();
|
||||||
|
match running_timer.upgrade() {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
match v.borrow().timer_type {
|
match v.borrow().timer_type {
|
||||||
TimerType::Timeout => {
|
TimerType::Timeout => {
|
||||||
@ -423,6 +441,15 @@ impl XTimer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn internal_modify(&mut self, timer_wp: XTimerWp, expire_time: i32) {
|
||||||
|
self.detach_timer(&timer_wp.upgrade().unwrap());
|
||||||
|
timer_wp.upgrade().unwrap().borrow_mut().expire_time = expire_time;
|
||||||
|
timer_wp.upgrade().unwrap().borrow_mut().expires =
|
||||||
|
(*self.get_tick_count.as_ref().unwrap())() +
|
||||||
|
expire_time as i64;
|
||||||
|
self.internal_add2(&timer_wp.upgrade().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_timeout(&mut self, time: i32, cb: TimerCb) -> XTimerWp {
|
pub fn set_timeout(&mut self, time: i32, cb: TimerCb) -> XTimerWp {
|
||||||
return self.internal_add(TimerType::Timeout, time, cb, None);
|
return self.internal_add(TimerType::Timeout, time, cb, None);
|
||||||
}
|
}
|
||||||
@ -463,7 +490,7 @@ impl XTimer {
|
|||||||
pub fn modify(&mut self, timer_wp: XTimerWp, expire_time: i32) {
|
pub fn modify(&mut self, timer_wp: XTimerWp, expire_time: i32) {
|
||||||
match timer_wp.upgrade() {
|
match timer_wp.upgrade() {
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
self.modify(timer_wp, expire_time);
|
self.internal_modify(timer_wp, expire_time);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user