Introduce IoEngine::YieldCurrentCoroutine()

This commit is contained in:
Alexander A. Klimov 2022-02-09 15:58:44 +01:00
parent 732d5c472d
commit 9585a63fa0
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) { if (availableSlots < 1) {
ioEngine.m_CpuBoundSemaphore.fetch_add(1); ioEngine.m_CpuBoundSemaphore.fetch_add(1);
ioEngine.m_AlreadyExpiredTimer.async_wait(yc); IoEngine::YieldCurrentCoroutine(yc);
continue; continue;
} }
@ -64,7 +64,7 @@ IoBoundWorkSlot::~IoBoundWorkSlot()
if (availableSlots < 1) { if (availableSlots < 1) {
ioEngine.m_CpuBoundSemaphore.fetch_add(1); ioEngine.m_CpuBoundSemaphore.fetch_add(1);
ioEngine.m_AlreadyExpiredTimer.async_wait(yc); IoEngine::YieldCurrentCoroutine(yc);
continue; continue;
} }

View File

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