add is_destory

This commit is contained in:
aozhiwei 2022-11-24 13:06:26 +08:00
parent 9d9efccd69
commit c02fdb4a92
4 changed files with 10 additions and 6 deletions

View File

@ -34,6 +34,7 @@ namespace a8
XTimerAttacher::~XTimerAttacher()
{
is_destory_ = true;
ClearTimerList();
}
@ -43,7 +44,7 @@ namespace a8
struct list_head* n = nullptr;
list_for_each_safe(pos, n, &timer_list_){
xtimer_list* tmp_timer = xtimer->GetTimerByAttach(pos);
xtimer->DeleteTimer(tmp_timer);
xtimer->DeleteTimer(tmp_timer, is_destory_);
}
}

View File

@ -24,6 +24,9 @@ namespace a8
XTimerAttacher();
~XTimerAttacher();
void ClearTimerList();
private:
bool is_destory_ = false;
};
}

View File

@ -248,7 +248,7 @@ namespace a8
}
}
void XTimer::DeleteTimer(xtimer_list* timer)
void XTimer::DeleteTimer(xtimer_list* timer, bool is_destory)
{
if (!timer) {
abort();
@ -257,7 +257,7 @@ namespace a8
base_->running_timer = nullptr;
}
if (timer->timer_after_func) {
timer->timer_after_func(timer->param);
timer->timer_after_func(timer->param, is_destory);
}
DetachTimer(timer);
if (!list_empty(&timer->attach_entry)) {
@ -356,7 +356,7 @@ namespace a8
}
AddToFreeList(timer);
if (timer->timer_after_func) {
timer->timer_after_func(timer->param);
timer->timer_after_func(timer->param, false);
}
}
break;

View File

@ -9,7 +9,7 @@ struct xtvec_base;
namespace a8
{
typedef void (*XTimerFunc)(const a8::XParams& param);
typedef void (*XTimerAfterFunc)(const a8::XParams& param);
typedef void (*XTimerAfterFunc)(const a8::XParams& param, bool is_destory);
typedef long long (*XGetTickCountFunc)(void*);
typedef struct list_head XTimerDestoryHandle;
struct XTimerPtr;
@ -41,7 +41,7 @@ namespace a8
void ModifyTimer(xtimer_list* timer, int expire_time);
void ModifyTimer(std::weak_ptr<XTimerPtr>& ptr, int expire_time);
//删除定时器
void DeleteTimer(xtimer_list* timer);
void DeleteTimer(xtimer_list* timer, bool is_destory = false);
//通过关联的list_head获取定时器对象
xtimer_list* GetTimerByAttach(list_head* attach_entry);
//获取定时器关联参数