51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#include <a8/a8.h>
|
|
|
|
#include <a8/timer.h>
|
|
#include <a8/xtimer.h>
|
|
#include <a8/timer_attacher.h>
|
|
|
|
namespace a8
|
|
{
|
|
|
|
TimerAttacher::TimerAttacher()
|
|
{
|
|
INIT_LIST_HEAD(&timer_list_);
|
|
}
|
|
|
|
TimerAttacher::~TimerAttacher()
|
|
{
|
|
ClearTimerList();
|
|
}
|
|
|
|
void TimerAttacher::ClearTimerList()
|
|
{
|
|
struct list_head* pos = nullptr;
|
|
struct list_head* n = nullptr;
|
|
list_for_each_safe(pos, n, &timer_list_){
|
|
timer_list* tmp_timer = a8::Timer::Instance()->GetTimerByAttach(pos);
|
|
a8::Timer::Instance()->DeleteTimer(tmp_timer);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
}
|