add GetRemainTimer
This commit is contained in:
parent
202f675e5f
commit
403fbb49bc
22
a8/timer.cc
22
a8/timer.cc
@ -243,6 +243,28 @@ namespace a8
|
||||
}
|
||||
}
|
||||
|
||||
a8::XParams* Timer::MutableParams(timer_list* timer)
|
||||
{
|
||||
if (!timer) {
|
||||
abort();
|
||||
}
|
||||
return &timer->param;
|
||||
}
|
||||
|
||||
long long Timer::GetRemainTime(timer_list* timer)
|
||||
{
|
||||
if (!timer) {
|
||||
abort();
|
||||
}
|
||||
long long remain_time = a8::XGetTickCount() - timer->expires;
|
||||
return std::max(remain_time, (long long)0);
|
||||
}
|
||||
|
||||
timer_list* Timer::GetRunningTimer()
|
||||
{
|
||||
return base_->running_timer;
|
||||
}
|
||||
|
||||
int Timer::GetIdleableMillSeconds()
|
||||
{
|
||||
#if 0
|
||||
|
@ -40,6 +40,12 @@ namespace a8
|
||||
void DeleteTimer(timer_list* timer);
|
||||
//通过关联的list_head获取定时器对象
|
||||
timer_list* GetTimerByAttach(list_head* attach_entry);
|
||||
//获取定时器关联参数
|
||||
a8::XParams* MutableParams(timer_list* timer);
|
||||
//获取定时器剩余时间
|
||||
long long GetRemainTime(timer_list* timer);
|
||||
//获取当前正在运行的定时器
|
||||
timer_list* GetRunningTimer();
|
||||
//获取定时器可怠速时间mill seconds
|
||||
int GetIdleableMillSeconds();
|
||||
|
||||
|
@ -262,6 +262,15 @@ namespace a8
|
||||
return &timer->param;
|
||||
}
|
||||
|
||||
long long XTimer::GetRemainTime(xtimer_list* timer)
|
||||
{
|
||||
if (!timer) {
|
||||
abort();
|
||||
}
|
||||
long long remain_time = get_tick_count_func_(context_) - timer->expires;
|
||||
return std::max(remain_time, (long long)0);
|
||||
}
|
||||
|
||||
xtimer_list* XTimer::GetRunningTimer()
|
||||
{
|
||||
return base_->running_timer;
|
||||
|
@ -40,7 +40,11 @@ namespace a8
|
||||
void DeleteTimer(xtimer_list* timer);
|
||||
//通过关联的list_head获取定时器对象
|
||||
xtimer_list* GetTimerByAttach(list_head* attach_entry);
|
||||
//获取定时器关联参数
|
||||
a8::XParams* MutableParams(xtimer_list* timer);
|
||||
//获取定时器剩余时间
|
||||
long long GetRemainTime(xtimer_list* timer);
|
||||
//获取当前正在运行的定时器
|
||||
xtimer_list* GetRunningTimer();
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user