diff --git a/a8/timer_attacher.cc b/a8/timer_attacher.cc index 48a2728..c3dd76b 100644 --- a/a8/timer_attacher.cc +++ b/a8/timer_attacher.cc @@ -1,6 +1,7 @@ #include #include +#include #include namespace a8 @@ -26,4 +27,24 @@ namespace a8 } } + XTimerAttacher::XTimerAttacher() + { + INIT_LIST_HEAD(&timer_list_); + } + + XTimerAttacher::~XTimerAttacher() + { + ClearTimerList(); + } + + void XTimerAttacher::ClearTimerList() + { + struct list_head* pos = nullptr; + struct list_head* n = nullptr; + list_for_each_safe(pos, n, &timer_list_){ + xtimer_list* tmp_timer = xtimer->GetTimerByAttach(pos); + xtimer->DeleteTimer(tmp_timer); + } + } + } diff --git a/a8/timer_attacher.h b/a8/timer_attacher.h index 457f1ff..5b900f3 100644 --- a/a8/timer_attacher.h +++ b/a8/timer_attacher.h @@ -14,6 +14,18 @@ namespace a8 void ClearTimerList(); }; + class XTimer; + class XTimerAttacher + { + public: + XTimer* xtimer = nullptr; + list_head timer_list_; + + XTimerAttacher(); + ~XTimerAttacher(); + void ClearTimerList(); + }; + } #endif