mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 21:24:41 +02:00
Rename AsioConditionVariable to AsioEvent
The current implementation is rather similar to Python's threading.Event, than to a CV.
This commit is contained in:
parent
a65f2d6b41
commit
331ba1f661
@ -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(io)
|
||||||
{
|
{
|
||||||
m_Timer.expires_at(init ? boost::posix_time::neg_infin : boost::posix_time::pos_infin);
|
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);
|
m_Timer.expires_at(boost::posix_time::neg_infin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsioConditionVariable::Clear()
|
void AsioEvent::Clear()
|
||||||
{
|
{
|
||||||
m_Timer.expires_at(boost::posix_time::pos_infin);
|
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;
|
boost::system::error_code ec;
|
||||||
m_Timer.async_wait(yc[ec]);
|
m_Timer.async_wait(yc[ec]);
|
||||||
|
@ -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
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class AsioConditionVariable
|
class AsioEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsioConditionVariable(boost::asio::io_context& io, bool init = false);
|
AsioEvent(boost::asio::io_context& io, bool init = false);
|
||||||
|
|
||||||
void Set();
|
void Set();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
@ -262,7 +262,7 @@ namespace icinga
|
|||||||
std::set<QueryPriority> m_SuppressedQueryKinds;
|
std::set<QueryPriority> m_SuppressedQueryKinds;
|
||||||
|
|
||||||
// Indicate that there's something to send/receive
|
// Indicate that there's something to send/receive
|
||||||
AsioConditionVariable m_QueuedWrites, m_QueuedReads;
|
AsioEvent m_QueuedWrites, m_QueuedReads;
|
||||||
|
|
||||||
std::function<void(boost::asio::yield_context& yc)> m_ConnectedCallback;
|
std::function<void(boost::asio::yield_context& yc)> m_ConnectedCallback;
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ private:
|
|||||||
double m_Seen;
|
double m_Seen;
|
||||||
boost::asio::io_context::strand m_IoStrand;
|
boost::asio::io_context::strand m_IoStrand;
|
||||||
std::vector<String> m_OutgoingMessagesQueue;
|
std::vector<String> m_OutgoingMessagesQueue;
|
||||||
AsioConditionVariable m_OutgoingMessagesQueued;
|
AsioEvent m_OutgoingMessagesQueued;
|
||||||
AsioConditionVariable m_WriterDone;
|
AsioEvent m_WriterDone;
|
||||||
Atomic<bool> m_ShuttingDown;
|
Atomic<bool> m_ShuttingDown;
|
||||||
boost::asio::deadline_timer m_CheckLivenessTimer, m_HeartbeatTimer;
|
boost::asio::deadline_timer m_CheckLivenessTimer, m_HeartbeatTimer;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user