diff --git a/orm_lib/src/DbClientLockFree.cc b/orm_lib/src/DbClientLockFree.cc index 35cfd14f..385130e2 100644 --- a/orm_lib/src/DbClientLockFree.cc +++ b/orm_lib/src/DbClientLockFree.cc @@ -131,13 +131,13 @@ void DbClientLockFree::execSql(std::string &&sql, } //LOG_TRACE << "Push query to buffer"; - _sqlCmdBuffer.emplace_back(std::move(sql), - paraNum, - std::move(parameters), - std::move(length), - std::move(format), - std::move(rcb), - std::move(exceptCallback)); + _sqlCmdBuffer.emplace_back(std::make_shared(std::move(sql), + paraNum, + std::move(parameters), + std::move(length), + std::move(format), + std::move(rcb), + std::move(exceptCallback))); } std::shared_ptr DbClientLockFree::newTransaction(const std::function &commitCallback) @@ -228,15 +228,15 @@ void DbClientLockFree::handleNewTask(const DbConnectionPtr &conn) if (!_sqlCmdBuffer.empty()) { - auto &cmd = _sqlCmdBuffer.front(); - conn->execSql(std::move(cmd._sql), - cmd._paraNum, - std::move(cmd._parameters), - std::move(cmd._length), - std::move(cmd._format), - std::move(cmd._cb), - std::move(cmd._exceptCb)); + auto cmdPtr = std::move(_sqlCmdBuffer.front()); _sqlCmdBuffer.pop_front(); + conn->execSql(std::move(cmdPtr->_sql), + cmdPtr->_paraNum, + std::move(cmdPtr->_parameters), + std::move(cmdPtr->_length), + std::move(cmdPtr->_format), + std::move(cmdPtr->_cb), + std::move(cmdPtr->_exceptCb)); return; } } diff --git a/orm_lib/src/DbClientLockFree.h b/orm_lib/src/DbClientLockFree.h index 26b694cd..f6076443 100644 --- a/orm_lib/src/DbClientLockFree.h +++ b/orm_lib/src/DbClientLockFree.h @@ -79,7 +79,8 @@ class DbClientLockFree : public DbClient, public std::enable_shared_from_this _sqlCmdBuffer; + + std::deque> _sqlCmdBuffer; std::queue &)>> _transCallbacks;