1
This commit is contained in:
parent
e4a9fab0ef
commit
e4877b7fa4
@ -268,8 +268,7 @@ namespace a8
|
|||||||
context->xtimer.AddDeadLineTimer
|
context->xtimer.AddDeadLineTimer
|
||||||
(
|
(
|
||||||
param.param1,
|
param.param1,
|
||||||
a8::Args({}),
|
[client] (int event, const a8::Args* args)
|
||||||
[client] (int event, const a8::Args& args, const a8::Args* user_args)
|
|
||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
client->DoAsyncClose();
|
client->DoAsyncClose();
|
||||||
|
27
a8/xtimer.cc
27
a8/xtimer.cc
@ -42,7 +42,6 @@ struct xtimer_list {
|
|||||||
struct xtvec_base *base;
|
struct xtvec_base *base;
|
||||||
|
|
||||||
a8::TimerCbProc cb;
|
a8::TimerCbProc cb;
|
||||||
a8::Args args;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct XTimerDestoryHandleNode
|
struct XTimerDestoryHandleNode
|
||||||
@ -104,7 +103,7 @@ static inline int DetachTimer(struct xtimer_list *timer)
|
|||||||
|
|
||||||
static inline void InitTimerList(xtvec_base* base, xtimer_list* timer, int timer_type,
|
static inline void InitTimerList(xtvec_base* base, xtimer_list* timer, int timer_type,
|
||||||
long long expires, int expire_time,
|
long long expires, int expire_time,
|
||||||
a8::Args args, a8::TimerCbProc cb)
|
a8::TimerCbProc cb)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&timer->destory_handle_list);
|
INIT_LIST_HEAD(&timer->destory_handle_list);
|
||||||
INIT_LIST_HEAD(&timer->entry);
|
INIT_LIST_HEAD(&timer->entry);
|
||||||
@ -115,7 +114,6 @@ static inline void InitTimerList(xtvec_base* base, xtimer_list* timer, int timer
|
|||||||
timer->fixed_timer_execute_times = 0;
|
timer->fixed_timer_execute_times = 0;
|
||||||
timer->base = base;
|
timer->base = base;
|
||||||
timer->cb = std::move(cb);
|
timer->cb = std::move(cb);
|
||||||
timer->args = std::move(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace a8
|
namespace a8
|
||||||
@ -159,8 +157,7 @@ namespace a8
|
|||||||
base_->timer_tick = get_tick_count_func_(context_);
|
base_->timer_tick = get_tick_count_func_(context_);
|
||||||
AddRepeatTimer
|
AddRepeatTimer
|
||||||
(gc_time_,
|
(gc_time_,
|
||||||
a8::Args({}),
|
[this] (int event, const a8::Args* args)
|
||||||
[this] (int event, const a8::Args& args, const a8::Args* user_args)
|
|
||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -188,7 +185,6 @@ namespace a8
|
|||||||
|
|
||||||
void XTimer::AddDeadLineTimer(
|
void XTimer::AddDeadLineTimer(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher
|
a8::XTimerAttacher* attacher
|
||||||
)
|
)
|
||||||
@ -198,7 +194,6 @@ namespace a8
|
|||||||
|
|
||||||
std::weak_ptr<XTimerPtr> XTimer::AddDeadLineTimerEx(
|
std::weak_ptr<XTimerPtr> XTimer::AddDeadLineTimerEx(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher
|
a8::XTimerAttacher* attacher
|
||||||
)
|
)
|
||||||
@ -208,7 +203,6 @@ namespace a8
|
|||||||
|
|
||||||
void XTimer::AddRepeatTimer(
|
void XTimer::AddRepeatTimer(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher)
|
a8::XTimerAttacher* attacher)
|
||||||
{
|
{
|
||||||
@ -217,7 +211,6 @@ namespace a8
|
|||||||
|
|
||||||
std::weak_ptr<XTimerPtr> XTimer::AddRepeatTimerEx(
|
std::weak_ptr<XTimerPtr> XTimer::AddRepeatTimerEx(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher)
|
a8::XTimerAttacher* attacher)
|
||||||
{
|
{
|
||||||
@ -270,11 +263,25 @@ namespace a8
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTimer::DeleteRunningTimer()
|
void XTimer::DeleteCurrentTimer()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool XTimer::IsRunningTimer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void XTimer::Clear()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void XTimer::UpdateTimer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
xtimer_list* XTimer::AddDeadLineTimer(int expire_time, a8::XParams param, a8::XTimerFunc timer_func,
|
xtimer_list* XTimer::AddDeadLineTimer(int expire_time, a8::XParams param, a8::XTimerFunc timer_func,
|
||||||
a8::XTimerAfterFunc timer_after_func)
|
a8::XTimerAfterFunc timer_after_func)
|
||||||
|
11
a8/xtimer.h
11
a8/xtimer.h
@ -10,11 +10,11 @@ namespace a8
|
|||||||
{
|
{
|
||||||
|
|
||||||
const int TIMER_EXEC_EVENT = 1;
|
const int TIMER_EXEC_EVENT = 1;
|
||||||
const int TIMER_DELETE_EVNET = 2;
|
const int TIMER_DELETE_EVENT = 2;
|
||||||
const int TIMER_DESTORY_EVNET = 3;
|
const int TIMER_DESTORY_EVNET = 3;
|
||||||
const int TIMER_USER_EVNET = 66;
|
const int TIMER_USER_EVNET = 66;
|
||||||
|
|
||||||
typedef std::function<void(int, const a8::Args&, const a8::Args*)> TimerCbProc;
|
typedef std::function<void(int, const a8::Args*)> TimerCbProc;
|
||||||
|
|
||||||
typedef long long (*XGetTickCountFunc)(void*);
|
typedef long long (*XGetTickCountFunc)(void*);
|
||||||
typedef struct list_head XTimerDestoryHandle;
|
typedef struct list_head XTimerDestoryHandle;
|
||||||
@ -33,14 +33,12 @@ namespace a8
|
|||||||
//添加截止时间定时器(一次性定时器)
|
//添加截止时间定时器(一次性定时器)
|
||||||
void AddDeadLineTimer(
|
void AddDeadLineTimer(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher = nullptr
|
a8::XTimerAttacher* attacher = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
std::weak_ptr<XTimerPtr> AddDeadLineTimerEx(
|
std::weak_ptr<XTimerPtr> AddDeadLineTimerEx(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher = nullptr
|
a8::XTimerAttacher* attacher = nullptr
|
||||||
);
|
);
|
||||||
@ -48,13 +46,11 @@ namespace a8
|
|||||||
//添加重复执行定时器(周期性定时器)
|
//添加重复执行定时器(周期性定时器)
|
||||||
void AddRepeatTimer(
|
void AddRepeatTimer(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher = nullptr);
|
a8::XTimerAttacher* attacher = nullptr);
|
||||||
|
|
||||||
std::weak_ptr<XTimerPtr> AddRepeatTimerEx(
|
std::weak_ptr<XTimerPtr> AddRepeatTimerEx(
|
||||||
int expire_time,
|
int expire_time,
|
||||||
a8::Args args,
|
|
||||||
a8::TimerCbProc timer_cb,
|
a8::TimerCbProc timer_cb,
|
||||||
a8::XTimerAttacher* attacher = nullptr);
|
a8::XTimerAttacher* attacher = nullptr);
|
||||||
|
|
||||||
@ -68,7 +64,8 @@ namespace a8
|
|||||||
//获取定时器剩余时间
|
//获取定时器剩余时间
|
||||||
long long GetRemainTime(std::weak_ptr<XTimerPtr>& timer_ptr);
|
long long GetRemainTime(std::weak_ptr<XTimerPtr>& timer_ptr);
|
||||||
//删除当前运行中定时器
|
//删除当前运行中定时器
|
||||||
void DeleteRunningTimer();
|
void DeleteCurrentTimer();
|
||||||
|
bool IsRunningTimer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//销毁定时器
|
//销毁定时器
|
||||||
|
Loading…
x
Reference in New Issue
Block a user