From 9018385c1a458ba8b7310cf4beaac68d428d7bf0 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 7 Feb 2024 11:24:10 +0100 Subject: [PATCH] CpuBoundWork#~CpuBoundWork(): just call #Done() to deduplicate code --- lib/base/io-engine.cpp | 7 ------- lib/base/io-engine.hpp | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/base/io-engine.cpp b/lib/base/io-engine.cpp index 7928ab19d..b8908a313 100644 --- a/lib/base/io-engine.cpp +++ b/lib/base/io-engine.cpp @@ -34,13 +34,6 @@ CpuBoundWork::CpuBoundWork(boost::asio::yield_context yc) } } -CpuBoundWork::~CpuBoundWork() -{ - if (!m_Done) { - IoEngine::Get().m_CpuBoundSemaphore.fetch_add(1); - } -} - void CpuBoundWork::Done() { if (!m_Done) { diff --git a/lib/base/io-engine.hpp b/lib/base/io-engine.hpp index bc842912b..4fe34debf 100644 --- a/lib/base/io-engine.hpp +++ b/lib/base/io-engine.hpp @@ -42,7 +42,11 @@ public: CpuBoundWork(CpuBoundWork&&) = delete; CpuBoundWork& operator=(const CpuBoundWork&) = delete; CpuBoundWork& operator=(CpuBoundWork&&) = delete; - ~CpuBoundWork(); + + inline ~CpuBoundWork() + { + Done(); + } void Done();