This commit is contained in:
aozhiwei 2022-12-17 15:24:46 +08:00
parent dec7ea7a3a
commit 6ca822b2c7
3 changed files with 27 additions and 29 deletions

View File

@ -12,7 +12,6 @@
#include <a8/mysql.h> #include <a8/mysql.h>
#include <a8/list.h> #include <a8/list.h>
#include <a8/timer.h>
#include <a8/timer_attacher.h> #include <a8/timer_attacher.h>
#include <f8/udplog.h> #include <f8/udplog.h>
#include <a8/mutable_xobject.h> #include <a8/mutable_xobject.h>
@ -20,6 +19,7 @@
#include <f8/dbpool.h> #include <f8/dbpool.h>
#include <f8/msgqueue.h> #include <f8/msgqueue.h>
#include <f8/utils.h> #include <f8/utils.h>
#include <f8/timer.h>
namespace f8 namespace f8
{ {
@ -46,7 +46,7 @@ namespace f8
time_t add_time = 0; time_t add_time = 0;
AsyncDBOnOkFunc on_ok = nullptr; AsyncDBOnOkFunc on_ok = nullptr;
AsyncDBOnErrorFunc on_error = nullptr; AsyncDBOnErrorFunc on_error = nullptr;
a8::TimerAttacher timer_attacher; f8::Attacher timer_attacher;
}; };
struct AsyncQueryNode struct AsyncQueryNode
@ -449,24 +449,24 @@ namespace f8
conn_info.DeepCopy(node->conn_info); conn_info.DeepCopy(node->conn_info);
db_thread->AddAsyncQuery(node); db_thread->AddAsyncQuery(node);
} }
a8::Timer::Instance()->AddDeadLineTimerAndAttach int msgid = exec_async_query_msgid;
f8::Timer::Instance()->SetTimeoutEx
(1000 * 10, (1000 * 10,
a8::XParams() [p, msgid] (int event, const a8::Args* args)
.SetSender(p->context_id)
.SetParam1(exec_async_query_msgid),
[] (const a8::XParams& param)
{ {
MsgQueue::Instance()->PostMsg if (event == a8::TIMER_EXEC_EVENT) {
(param.param1.GetInt(), MsgQueue::Instance()->PostMsg
a8::Args (msgid,
( a8::Args
{ (
param.sender.GetInt(), {
AQE_CONN_ERROR p->context_id,
} AQE_CONN_ERROR
)); }
));
}
}, },
&p->timer_attacher.timer_list_); &p->timer_attacher);
++DBPool::Instance()->total_query_num; ++DBPool::Instance()->total_query_num;
} }

View File

@ -15,7 +15,6 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <a8/list.h> #include <a8/list.h>
#include <a8/timer.h>
#include <a8/timer_attacher.h> #include <a8/timer_attacher.h>
#include <a8/curl.h> #include <a8/curl.h>
#include <a8/mutable_xobject.h> #include <a8/mutable_xobject.h>
@ -24,6 +23,7 @@
#include <f8/httpclientpool.h> #include <f8/httpclientpool.h>
#include <f8/msgqueue.h> #include <f8/msgqueue.h>
#include <f8/utils.h> #include <f8/utils.h>
#include <f8/timer.h>
#define F8_MUTLI_THREAD_HTTP 1 #define F8_MUTLI_THREAD_HTTP 1
@ -43,7 +43,7 @@ namespace f8
time_t add_time = 0; time_t add_time = 0;
AsyncHttpOnOkFunc on_ok = nullptr; AsyncHttpOnOkFunc on_ok = nullptr;
AsyncHttpOnErrorFunc on_error = nullptr; AsyncHttpOnErrorFunc on_error = nullptr;
a8::TimerAttacher timer_attacher; f8::Attacher timer_attacher;
}; };
struct AsyncHttpNode struct AsyncHttpNode
@ -419,15 +419,13 @@ namespace f8
http_thread->AddAsyncHttp(node); http_thread->AddAsyncHttp(node);
#endif #endif
} }
a8::Timer::Instance()->AddDeadLineTimerAndAttach(1000 * 10, f8::Timer::Instance()->SetTimeoutEx
a8::XParams() (1000 * 10,
.SetSender(this) [p] (int event, const a8::Args* args)
.SetParam1(p->context_id), {
[] (const a8::XParams& param)
{
}, },
&p->timer_attacher.timer_list_); &p->timer_attacher);
} }
#if F8_MUTLI_THREAD_HTTP #if F8_MUTLI_THREAD_HTTP

View File

@ -6,9 +6,9 @@
#include <f8/f8.h> #include <f8/f8.h>
#include <a8/timer.h> #include <f8/timer.h>
#include "f8/msgqueue.h" #include <f8/msgqueue.h>
namespace f8 namespace f8
{ {