Use shared_ptr to store sql query in cache in the DbClientLockFree class
This commit is contained in:
parent
6adff3469c
commit
353790f90b
|
@ -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<SqlCmd>(std::move(sql),
|
||||
paraNum,
|
||||
std::move(parameters),
|
||||
std::move(length),
|
||||
std::move(format),
|
||||
std::move(rcb),
|
||||
std::move(exceptCallback)));
|
||||
}
|
||||
|
||||
std::shared_ptr<Transaction> DbClientLockFree::newTransaction(const std::function<void(bool)> &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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,8 @@ class DbClientLockFree : public DbClient, public std::enable_shared_from_this<Db
|
|||
{
|
||||
}
|
||||
};
|
||||
std::deque<SqlCmd> _sqlCmdBuffer;
|
||||
|
||||
std::deque<std::shared_ptr<SqlCmd>> _sqlCmdBuffer;
|
||||
|
||||
std::queue<std::function<void(const std::shared_ptr<Transaction> &)>> _transCallbacks;
|
||||
|
||||
|
|
Loading…
Reference in New Issue