add XTimerAttacher

This commit is contained in:
aozhiwei 2019-04-15 11:51:13 +08:00
parent f85d842169
commit bf2310bf6f
2 changed files with 33 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include <a8/a8.h>
#include <a8/timer.h>
#include <a8/xtimer.h>
#include <a8/timer_attacher.h>
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);
}
}
}

View File

@ -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