mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
Allow CpuBoundWork to be done before end of scope
This commit is contained in:
parent
e21956e26e
commit
2d7714802d
@ -31,6 +31,7 @@
|
|||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
CpuBoundWork::CpuBoundWork(boost::asio::yield_context yc)
|
CpuBoundWork::CpuBoundWork(boost::asio::yield_context yc)
|
||||||
|
: m_Done(false)
|
||||||
{
|
{
|
||||||
auto& ioEngine (IoEngine::Get());
|
auto& ioEngine (IoEngine::Get());
|
||||||
|
|
||||||
@ -49,7 +50,18 @@ CpuBoundWork::CpuBoundWork(boost::asio::yield_context yc)
|
|||||||
|
|
||||||
CpuBoundWork::~CpuBoundWork()
|
CpuBoundWork::~CpuBoundWork()
|
||||||
{
|
{
|
||||||
IoEngine::Get().m_CpuBoundSemaphore.fetch_add(1);
|
if (!m_Done) {
|
||||||
|
IoEngine::Get().m_CpuBoundSemaphore.fetch_add(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CpuBoundWork::Done()
|
||||||
|
{
|
||||||
|
if (!m_Done) {
|
||||||
|
IoEngine::Get().m_CpuBoundSemaphore.fetch_add(1);
|
||||||
|
|
||||||
|
m_Done = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyInit<std::unique_ptr<IoEngine>> IoEngine::m_Instance ([]() { return std::unique_ptr<IoEngine>(new IoEngine()); });
|
LazyInit<std::unique_ptr<IoEngine>> IoEngine::m_Instance ([]() { return std::unique_ptr<IoEngine>(new IoEngine()); });
|
||||||
|
@ -48,6 +48,11 @@ public:
|
|||||||
CpuBoundWork& operator=(const CpuBoundWork&) = delete;
|
CpuBoundWork& operator=(const CpuBoundWork&) = delete;
|
||||||
CpuBoundWork& operator=(CpuBoundWork&&) = delete;
|
CpuBoundWork& operator=(CpuBoundWork&&) = delete;
|
||||||
~CpuBoundWork();
|
~CpuBoundWork();
|
||||||
|
|
||||||
|
void Done();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_Done;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user