diff --git a/lib/base/io-engine.cpp b/lib/base/io-engine.cpp index 3190ed03d..30e2512d4 100644 --- a/lib/base/io-engine.cpp +++ b/lib/base/io-engine.cpp @@ -124,23 +124,23 @@ void IoEngine::RunEventLoop() } } -AsioConditionVariable::AsioConditionVariable(boost::asio::io_context& io, bool init) +AsioEvent::AsioEvent(boost::asio::io_context& io, bool init) : m_Timer(io) { m_Timer.expires_at(init ? boost::posix_time::neg_infin : boost::posix_time::pos_infin); } -void AsioConditionVariable::Set() +void AsioEvent::Set() { m_Timer.expires_at(boost::posix_time::neg_infin); } -void AsioConditionVariable::Clear() +void AsioEvent::Clear() { m_Timer.expires_at(boost::posix_time::pos_infin); } -void AsioConditionVariable::Wait(boost::asio::yield_context yc) +void AsioEvent::Wait(boost::asio::yield_context yc) { boost::system::error_code ec; m_Timer.async_wait(yc[ec]); diff --git a/lib/base/io-engine.hpp b/lib/base/io-engine.hpp index 64831ff8c..049523e52 100644 --- a/lib/base/io-engine.hpp +++ b/lib/base/io-engine.hpp @@ -158,14 +158,14 @@ class TerminateIoThread : public std::exception }; /** - * Condition variable which doesn't block I/O threads + * Awaitable flag which doesn't block I/O threads, inspired by threading.Event from Python * * @ingroup base */ -class AsioConditionVariable +class AsioEvent { public: - AsioConditionVariable(boost::asio::io_context& io, bool init = false); + AsioEvent(boost::asio::io_context& io, bool init = false); void Set(); void Clear(); diff --git a/lib/icingadb/redisconnection.hpp b/lib/icingadb/redisconnection.hpp index acc6e4381..2038f797c 100644 --- a/lib/icingadb/redisconnection.hpp +++ b/lib/icingadb/redisconnection.hpp @@ -262,7 +262,7 @@ namespace icinga std::set m_SuppressedQueryKinds; // Indicate that there's something to send/receive - AsioConditionVariable m_QueuedWrites, m_QueuedReads; + AsioEvent m_QueuedWrites, m_QueuedReads; std::function m_ConnectedCallback; diff --git a/lib/remote/jsonrpcconnection.hpp b/lib/remote/jsonrpcconnection.hpp index ef83dce1b..826d3b46a 100644 --- a/lib/remote/jsonrpcconnection.hpp +++ b/lib/remote/jsonrpcconnection.hpp @@ -75,8 +75,8 @@ private: double m_Seen; boost::asio::io_context::strand m_IoStrand; std::vector m_OutgoingMessagesQueue; - AsioConditionVariable m_OutgoingMessagesQueued; - AsioConditionVariable m_WriterDone; + AsioEvent m_OutgoingMessagesQueued; + AsioEvent m_WriterDone; Atomic m_ShuttingDown; boost::asio::deadline_timer m_CheckLivenessTimer, m_HeartbeatTimer;