From bf2310bf6f9ef891874ff1f0bddfd9dc68db5863 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 15 Apr 2019 11:51:13 +0800 Subject: [PATCH] add XTimerAttacher --- a8/timer_attacher.cc | 21 +++++++++++++++++++++ a8/timer_attacher.h | 12 ++++++++++++ 2 files changed, 33 insertions(+) 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