mirror of https://github.com/Icinga/icinga2.git
Use IoEngine::Spawn wrapper in RedisConnection class
This avoids multiple locations for `asio::spawn` calls.
This commit is contained in:
parent
7caa0867b3
commit
8f5375d2bb
|
@ -39,14 +39,14 @@ void RedisConnection::Start()
|
|||
if (!m_Started.exchange(true)) {
|
||||
Ptr keepAlive (this);
|
||||
|
||||
asio::spawn(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) { ReadLoop(yc); });
|
||||
IoEngine::SpawnCoroutine(m_Strand, [this, keepAlive](asio::yield_context yc) { WriteLoop(yc); });
|
||||
}
|
||||
|
||||
if (!m_Connecting.exchange(true)) {
|
||||
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); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "base/shared.hpp"
|
||||
#include "base/string.hpp"
|
||||
#include "base/value.hpp"
|
||||
#include <boost/asio/spawn.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/buffered_stream.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
@ -304,7 +303,7 @@ RedisConnection::Reply RedisConnection::ReadOne(StreamPtr& stream, boost::asio::
|
|||
if (!m_Connecting.exchange(true)) {
|
||||
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)) {
|
||||
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); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue