diff --git a/third_party/a8/a8/args.h b/third_party/a8/a8/args.cc similarity index 59% rename from third_party/a8/a8/args.h rename to third_party/a8/a8/args.cc index 605c51b..7e8a763 100644 --- a/third_party/a8/a8/args.h +++ b/third_party/a8/a8/args.cc @@ -1,10 +1,11 @@ -#pragma once +module; #include #include -namespace a8 -{ +export module a8m.args; + +export namespace a8m { class Args { public: @@ -12,7 +13,7 @@ namespace a8 Args(std::vector args):args_(std::move(args)) {}; template - T Get(size_t index) const { return std::any_cast(args_.at(index));}; + T Get(size_t index) const { /*return std::any_cast(args_.at(index));*/ return T(); }; private: std::vector args_; diff --git a/third_party/a8/a8/types.h b/third_party/a8/a8/types.h index d1cf05b..246eb4b 100644 --- a/third_party/a8/a8/types.h +++ b/third_party/a8/a8/types.h @@ -3,7 +3,7 @@ #include #include -#include +import a8m.args; namespace google { @@ -26,8 +26,8 @@ namespace a8 SendQueueNode* next; }; - typedef std::function CommonCbProc; - typedef std::function CommonCbProcEx; + typedef std::function CommonCbProc; + typedef std::function CommonCbProcEx; typedef std::weak_ptr XTimerWp; namespace reflect diff --git a/third_party/a8/a8/xtimer.cc b/third_party/a8/a8/xtimer.cc index 97dad89..fcfd918 100644 --- a/third_party/a8/a8/xtimer.cc +++ b/third_party/a8/a8/xtimer.cc @@ -143,7 +143,7 @@ namespace a8 base_->timer_tick = get_tick_count_func_(context_); InternalSetInterval (gc_time_, - [this] (int event, const a8::Args* args) + [this] (int event, const a8m::Args* args) { if (a8m::TIMER_EXEC_EVENT() == event) { int i = 0; @@ -210,7 +210,7 @@ namespace a8 } } - void InternalFireEvent(xtimer_list* timer, int event, a8::Args* args) + void InternalFireEvent(xtimer_list* timer, int event, a8m::Args* args) { if (timer->cb) { timer->cb(event, args); @@ -556,7 +556,7 @@ namespace a8 return result; } - void XTimer::FireEvent(XTimerWp& timer_wp, int event, a8::Args* args) + void XTimer::FireEvent(XTimerWp& timer_wp, int event, a8m::Args* args) { if (timer_wp.expired()) { abort(); diff --git a/third_party/a8/a8/xtimer.h b/third_party/a8/a8/xtimer.h index d5d50af..2dcf60d 100644 --- a/third_party/a8/a8/xtimer.h +++ b/third_party/a8/a8/xtimer.h @@ -2,12 +2,13 @@ #include -#include #include +import a8m.args; + namespace a8 { - typedef std::function TimerCb; + typedef std::function TimerCb; typedef long long (*XGetTickCountFunc)(void*); class Attacher; @@ -30,7 +31,7 @@ namespace a8 XTimerWp SetIntervalWp(int expire_time, TimerCb cb); XTimerWp SetIntervalWpEx(int expire_time, TimerCb cb, Attacher* attacher); - void FireEvent(XTimerWp& timer_wp, int event, a8::Args* args); + void FireEvent(XTimerWp& timer_wp, int event, a8m::Args* args); void ModifyTime(XTimerWp& timer_wp, int expire_time); void ResetTimer(XTimerWp& timer_wp); void Delete(XTimerWp& timer_wp); diff --git a/third_party/f8/f8/httpclientpool.cc b/third_party/f8/f8/httpclientpool.cc index d271679..9661170 100644 --- a/third_party/f8/f8/httpclientpool.cc +++ b/third_party/f8/f8/httpclientpool.cc @@ -21,11 +21,14 @@ #include #include #include +#include #include static const int AHE_NO_ERROR = 0; static const int AHE_NO_CONN = 1; +import a8m.args; + namespace f8 { @@ -217,7 +220,7 @@ namespace f8 if (xobj->ReadFromJsonString(response)) { f8::MsgQueue::Instance()->PostMsg (IM_HttpClientPool, - a8::Args + a8m::Args ( { node->context_id, @@ -228,7 +231,7 @@ namespace f8 } else { f8::MsgQueue::Instance()->PostMsg (IM_HttpClientPool, - a8::Args + a8m::Args ( { node->context_id, @@ -241,7 +244,7 @@ namespace f8 } else { f8::MsgQueue::Instance()->PostMsg (IM_HttpClientPool, - a8::Args + a8m::Args ( { node->context_id, @@ -403,7 +406,7 @@ namespace f8 } f8::Timer::Instance()->SetTimeoutEx (1000 * 10, - [p] (int event, const a8::Args* args) + [p] (int event, const a8m::Args* args) { }, @@ -446,9 +449,14 @@ namespace f8 impl_->Init(); MsgQueue::Instance()->RegisterCallBack (IM_HttpClientPool, - [] (const a8::Args& args) + [] (const a8m::Args& args) { --(HttpClientPool::Instance()->impl_->pending_num); + #if 1 + std::vector args_; + auto a = std::any_cast(args_.at(0)); + #endif + #if 0 long long context_id = args.Get(0); int code = args.Get(1); auto xobj = args.Get>(2); @@ -461,6 +469,7 @@ namespace f8 response ); } + #endif } ); impl_->SetThreadNum(thread_num); diff --git a/third_party/f8/f8/jsonhttprequest.cc b/third_party/f8/f8/jsonhttprequest.cc index bafa10f..eb1a27c 100644 --- a/third_party/f8/f8/jsonhttprequest.cc +++ b/third_party/f8/f8/jsonhttprequest.cc @@ -37,7 +37,7 @@ namespace f8 if (cb_) { std::string response; resp_xobj_->ToJsonStr(response); - cb_(a8::Args({a8::HttpResponse(response)})); + cb_(a8m::Args({a8::HttpResponse(response)})); } resped_ = true; } diff --git a/third_party/f8/f8/jsonhttprequest.h b/third_party/f8/f8/jsonhttprequest.h index 78bf892..5f59640 100644 --- a/third_party/f8/f8/jsonhttprequest.h +++ b/third_party/f8/f8/jsonhttprequest.h @@ -1,7 +1,8 @@ #pragma once #include -#include + +import a8m.args; namespace a8 { diff --git a/third_party/f8/f8/msgqueue.cc b/third_party/f8/f8/msgqueue.cc index 4f29c51..77b96e6 100644 --- a/third_party/f8/f8/msgqueue.cc +++ b/third_party/f8/f8/msgqueue.cc @@ -21,10 +21,10 @@ namespace f8 struct IMMsgNode { int msgid; - const a8::Args args; + const a8m::Args args; IMMsgNode* next = nullptr; - IMMsgNode(const a8::Args& args1):args(std::move(args1)) + IMMsgNode(const a8m::Args& args1):args(std::move(args1)) { } @@ -83,7 +83,7 @@ namespace f8 } } - void ProcessMsg(int msgid, const a8::Args& args) + void ProcessMsg(int msgid, const a8m::Args& args) { auto itr = msg_handlers.find(msgid); if (itr != msg_handlers.end()) { @@ -113,7 +113,7 @@ namespace f8 return &node->entry; } - void PostMsg(int msgid, const a8::Args args) + void PostMsg(int msgid, const a8m::Args args) { IMMsgNode *p = new IMMsgNode(args); p->msgid = msgid; @@ -183,7 +183,7 @@ namespace f8 return imp_->RegisterCallBack(msgid, handle_func); } - void MsgQueue::PostMsg(int msgid, const a8::Args args) + void MsgQueue::PostMsg(int msgid, const a8m::Args args) { imp_->PostMsg(msgid, std::move(args)); } diff --git a/third_party/f8/f8/msgqueue.h b/third_party/f8/f8/msgqueue.h index c77715b..b887730 100644 --- a/third_party/f8/f8/msgqueue.h +++ b/third_party/f8/f8/msgqueue.h @@ -3,11 +3,12 @@ #include #include -#include + +import a8m.args; namespace f8 { - typedef std::function MsgHandleFunc; + typedef std::function MsgHandleFunc; typedef list_head* CallBackHandle; class MsgQueue : public a8::Singleton @@ -25,7 +26,7 @@ namespace f8 CallBackHandle RegisterCallBack(int msgid, MsgHandleFunc cb); void RemoveCallBack(CallBackHandle handle); - void PostMsg(int msgid, const a8::Args args); + void PostMsg(int msgid, const a8m::Args args); private: std::shared_ptr imp_; diff --git a/third_party/f8/f8/timer.cc b/third_party/f8/f8/timer.cc index ed4a6e6..904f15d 100644 --- a/third_party/f8/f8/timer.cc +++ b/third_party/f8/f8/timer.cc @@ -85,7 +85,7 @@ namespace f8 return TimerWp(xtimer_.SetIntervalWpEx(expire_time, cb, &attacher->p_)); } - void Timer::FireEvent(TimerWp& timer_wp, int event, a8::Args* args) + void Timer::FireEvent(TimerWp& timer_wp, int event, a8m::Args* args) { xtimer_.FireEvent(timer_wp.p_, event, args); } diff --git a/third_party/f8/f8/timer.h b/third_party/f8/f8/timer.h index 7fe233c..8f9ae91 100644 --- a/third_party/f8/f8/timer.h +++ b/third_party/f8/f8/timer.h @@ -53,7 +53,7 @@ namespace f8 TimerWp SetIntervalWp(int expire_time, a8::TimerCb cb); TimerWp SetIntervalWpEx(int expire_time, a8::TimerCb cb, Attacher* attacher); - void FireEvent(TimerWp& timer_wp, int event, a8::Args* args); + void FireEvent(TimerWp& timer_wp, int event, a8m::Args* args); void ModifyTime(TimerWp& timer_wp, int expire_time); void Delete(TimerWp& timer_wp); long long GetRemainTime(TimerWp& timer_wp);