RedisConnection#ExecuteQueries(): fire all queries at once

refs #49
This commit is contained in:
Alexander A. Klimov 2019-07-25 17:41:07 +02:00 committed by Michael Friedrich
parent 74eccf60f2
commit bb333b535b
2 changed files with 11 additions and 5 deletions

View File

@ -189,11 +189,9 @@ void RedisConnection::ExecuteQuery(const std::vector<String>& query, redisCallba
void
RedisConnection::ExecuteQueries(const std::vector<std::vector<String> >& queries, redisCallbackFn *fn, void *privdata)
{
for (const auto& query : queries) {
m_RedisConnectionWorkQueue.Enqueue([this, query, fn, privdata]() {
SendMessageInternal(query, fn, privdata);
});
}
m_RedisConnectionWorkQueue.Enqueue([this, queries, fn, privdata]() {
SendMessagesInternal(queries, fn, privdata);
});
}
void RedisConnection::SendMessageInternal(const std::vector<String>& query, redisCallbackFn *fn, void *privdata)
@ -248,3 +246,10 @@ void RedisConnection::SendMessageInternal(const std::vector<String>& query, redi
);
}
}
void RedisConnection::SendMessagesInternal(const std::vector<std::vector<String>>& queries, redisCallbackFn *fn, void *privdata)
{
for (const auto& query : queries) {
SendMessageInternal(query, fn, privdata);
}
}

View File

@ -69,6 +69,7 @@ namespace icinga
static void StaticInitialize();
void SendMessageInternal(const std::vector<String>& query, redisCallbackFn *fn, void *privdata);
void SendMessagesInternal(const std::vector<std::vector<String>>& queries, redisCallbackFn *fn, void *privdata);
void AssertOnWorkQueue();