Clean up the FinishAsyncQueries code a bit

refs #8714
This commit is contained in:
Gunnar Beutner 2015-12-14 10:33:43 +01:00
parent 8055f05d5e
commit 372cf07bc4
3 changed files with 4 additions and 14 deletions

View File

@ -117,8 +117,6 @@ void DbEvents::NextCheckChangedHandler(const Checkable::Ptr& checkable)
else
query1.WhereCriteria->Set("host_object_id", host);
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbObject::OnQuery(query1);
}

View File

@ -139,7 +139,7 @@ void IdoMysqlConnection::TxTimerHandler(void)
void IdoMysqlConnection::NewTransaction(void)
{
m_QueryQueue.Enqueue(boost::bind(&IdoMysqlConnection::InternalNewTransaction, this), PriorityHigh);
m_QueryQueue.Enqueue(boost::bind(&IdoMysqlConnection::FinishAsyncQueries, this, true), PriorityHigh);
m_QueryQueue.Enqueue(boost::bind(&IdoMysqlConnection::FinishAsyncQueries, this), PriorityHigh);
}
void IdoMysqlConnection::InternalNewTransaction(void)
@ -405,18 +405,10 @@ void IdoMysqlConnection::AsyncQuery(const String& query, const boost::function<v
aq.Query = query;
aq.Callback = callback;
m_AsyncQueries.push_back(aq);
if (m_AsyncQueries.size() > 500)
FinishAsyncQueries(true);
else
m_QueryQueue.Enqueue(boost::bind(&IdoMysqlConnection::FinishAsyncQueries, this, false), PriorityLow);
}
void IdoMysqlConnection::FinishAsyncQueries(bool force)
void IdoMysqlConnection::FinishAsyncQueries(void)
{
if (m_AsyncQueries.size() < 10 && !force)
return;
std::vector<IdoAsyncQuery> queries;
m_AsyncQueries.swap(queries);
@ -515,7 +507,7 @@ IdoMysqlResult IdoMysqlConnection::Query(const String& query)
AssertOnWorkQueue();
/* finish all async queries to maintain the right order for queries */
FinishAsyncQueries(true);
FinishAsyncQueries();
Log(LogDebug, "IdoMysqlConnection")
<< "Query: " << query;

View File

@ -90,7 +90,7 @@ private:
void DiscardRows(const IdoMysqlResult& result);
void AsyncQuery(const String& query, const IdoAsyncCallback& callback = IdoAsyncCallback());
void FinishAsyncQueries(bool force = false);
void FinishAsyncQueries(void);
bool FieldToEscapedString(const String& key, const Value& value, Value *result);
void InternalActivateObject(const DbObject::Ptr& dbobj);