Merge pull request #7759 from Icinga/bugfix/quality-redisconnection

Use IoEngine::Spawn wrapper in RedisConnection class
This commit is contained in:
Alexander Aleksandrovič Klimov 2020-01-16 10:57:36 +01:00 committed by GitHub
commit ba711943ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -39,14 +39,14 @@ void RedisConnection::Start()
if (!m_Started.exchange(true)) { if (!m_Started.exchange(true)) {
Ptr keepAlive (this); Ptr keepAlive (this);
asio::spawn(m_Strand, [this, keepAlive](asio::yield_context yc) { ReadLoop(yc); }); IoEngine::SpawnCoroutine(m_Strand, [this, keepAlive](asio::yield_context yc) { ReadLoop(yc); });
asio::spawn(m_Strand, [this, keepAlive](asio::yield_context yc) { WriteLoop(yc); }); IoEngine::SpawnCoroutine(m_Strand, [this, keepAlive](asio::yield_context yc) { WriteLoop(yc); });
} }
if (!m_Connecting.exchange(true)) { if (!m_Connecting.exchange(true)) {
Ptr keepAlive (this); Ptr keepAlive (this);
asio::spawn(m_Strand, [this, keepAlive](asio::yield_context yc) { Connect(yc); }); IoEngine::SpawnCoroutine(m_Strand, [this, keepAlive](asio::yield_context yc) { Connect(yc); });
} }
} }

View File

@ -10,7 +10,6 @@
#include "base/shared.hpp" #include "base/shared.hpp"
#include "base/string.hpp" #include "base/string.hpp"
#include "base/value.hpp" #include "base/value.hpp"
#include <boost/asio/spawn.hpp>
#include <boost/asio/buffer.hpp> #include <boost/asio/buffer.hpp>
#include <boost/asio/buffered_stream.hpp> #include <boost/asio/buffered_stream.hpp>
#include <boost/asio/io_context.hpp> #include <boost/asio/io_context.hpp>
@ -304,7 +303,7 @@ RedisConnection::Reply RedisConnection::ReadOne(StreamPtr& stream, boost::asio::
if (!m_Connecting.exchange(true)) { if (!m_Connecting.exchange(true)) {
Ptr keepAlive (this); Ptr keepAlive (this);
asio::spawn(m_Strand, [this, keepAlive](asio::yield_context yc) { Connect(yc); }); IoEngine::SpawnCoroutine(m_Strand, [this, keepAlive](asio::yield_context yc) { Connect(yc); });
} }
} }
@ -342,7 +341,7 @@ void RedisConnection::WriteOne(StreamPtr& stream, RedisConnection::Query& query,
if (!m_Connecting.exchange(true)) { if (!m_Connecting.exchange(true)) {
Ptr keepAlive (this); Ptr keepAlive (this);
asio::spawn(m_Strand, [this, keepAlive](asio::yield_context yc) { Connect(yc); }); IoEngine::SpawnCoroutine(m_Strand, [this, keepAlive](asio::yield_context yc) { Connect(yc); });
} }
} }