Introduce IoEngine::YieldCurrentCoroutine()

This commit is contained in:
Alexander A. Klimov 2022-02-09 15:58:44 +01:00
parent 59dd3592c2
commit 1d1e2b2888
2 changed files with 8 additions and 2 deletions

View File

@ -25,7 +25,7 @@ CpuBoundWork::CpuBoundWork(boost::asio::yield_context yc)
if (availableSlots < 1) {
ioEngine.m_CpuBoundSemaphore.fetch_add(1);
ioEngine.m_AlreadyExpiredTimer.async_wait(yc);
IoEngine::YieldCurrentCoroutine(yc);
continue;
}
@ -64,7 +64,7 @@ IoBoundWorkSlot::~IoBoundWorkSlot()
if (availableSlots < 1) {
ioEngine.m_CpuBoundSemaphore.fetch_add(1);
ioEngine.m_AlreadyExpiredTimer.async_wait(yc);
IoEngine::YieldCurrentCoroutine(yc);
continue;
}

View File

@ -119,6 +119,12 @@ public:
);
}
static inline
void YieldCurrentCoroutine(boost::asio::yield_context yc)
{
Get().m_AlreadyExpiredTimer.async_wait(yc);
}
private:
IoEngine();