add XTimerAttacher
This commit is contained in:
parent
f85d842169
commit
bf2310bf6f
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user