This commit is contained in:
aozhiwei 2018-11-26 21:26:02 +08:00
parent ca5ccaf83c
commit 6f668cf5c5
4 changed files with 400 additions and 387 deletions

View File

@ -15,6 +15,9 @@
#include "framework/cpp/msgqueue.h" #include "framework/cpp/msgqueue.h"
#include "framework/cpp/utils.h" #include "framework/cpp/utils.h"
namespace f8
{
enum AsyncQueryError enum AsyncQueryError
{ {
AQE_NO_ERROR = 0, AQE_NO_ERROR = 0,
@ -226,7 +229,7 @@ private:
{ {
int ret = last_query_->ExecQuery(node->_sql_fmt.c_str(), node->_sql_params); int ret = last_query_->ExecQuery(node->_sql_fmt.c_str(), node->_sql_params);
if (ret < 0) { if (ret < 0) {
MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid, f8::MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid,
a8::XParams() a8::XParams()
.SetSender(node->context_id) .SetSender(node->context_id)
.SetParam1(AQE_SYNTAX_ERROR) .SetParam1(AQE_SYNTAX_ERROR)
@ -243,7 +246,7 @@ private:
} }
last_query_->Next(); last_query_->Next();
} }
MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid, f8::MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid,
a8::XParams() a8::XParams()
.SetSender(node->context_id) .SetSender(node->context_id)
.SetParam1(AQE_NO_ERROR) .SetParam1(AQE_NO_ERROR)
@ -464,3 +467,4 @@ void DBPool::ExecAsyncScript(a8::XObject conn_info, const char* querystr, std::v
{ {
impl_->InternalExecAsyncSql(1, conn_info, querystr, args, param, on_ok, on_error, hash_code); impl_->InternalExecAsyncSql(1, conn_info, querystr, args, param, on_ok, on_error, hash_code);
} }
}

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
namespace f8
{
typedef std::vector<std::vector<std::string>> DataSet; typedef std::vector<std::vector<std::string>> DataSet;
typedef void (*AsyncDBOnOkFunc)(a8::XParams& param, const DataSet* data_set); typedef void (*AsyncDBOnOkFunc)(a8::XParams& param, const DataSet* data_set);
typedef void (*AsyncDBOnErrorFunc)(a8::XParams& param, int error_code, const std::string& error_msg); typedef void (*AsyncDBOnErrorFunc)(a8::XParams& param, int error_code, const std::string& error_msg);
@ -26,3 +28,4 @@ class DBPool : public a8::Singleton<DBPool>
private: private:
DBPoolImpl* impl_ = nullptr; DBPoolImpl* impl_ = nullptr;
}; };
}

View File

@ -5,6 +5,8 @@
#include "framework/cpp/msgqueue.h" #include "framework/cpp/msgqueue.h"
#include "app.h" #include "app.h"
namespace f8
{
struct MsgQueueNode struct MsgQueueNode
{ {
struct list_head entry; struct list_head entry;
@ -114,3 +116,4 @@ void MsgQueue::PostMsg_r(int msgid, a8::XParams param)
param.DeepCopy(*p); param.DeepCopy(*p);
App::Instance()->AddIMMsg(f8::IM_SysMsgQueue, a8::XParams().SetSender(msgid).SetParam1((void*)p)); App::Instance()->AddIMMsg(f8::IM_SysMsgQueue, a8::XParams().SetSender(msgid).SetParam1((void*)p));
} }
}

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
namespace f8
{
typedef std::function<void (const a8::XParams& param)> MsgHandleFunc; typedef std::function<void (const a8::XParams& param)> MsgHandleFunc;
typedef list_head* CallBackHandle; typedef list_head* CallBackHandle;
@ -28,3 +30,4 @@ class MsgQueue : public a8::Singleton<MsgQueue>
private: private:
MsgQueueImp* imp_ = nullptr; MsgQueueImp* imp_ = nullptr;
}; };
}