diff --git a/core/semaphore.hh b/core/semaphore.hh index a63c53aa8e4..2051eb8a84f 100644 --- a/core/semaphore.hh +++ b/core/semaphore.hh @@ -307,6 +307,12 @@ public: _sem.signal(_n); } } + /// Releases ownership of the units. The semaphore will not be signalled. + /// + /// \return the number of units held + size_t release() { + return std::exchange(_n, 0); + } }; /// \brief Take units from semaphore temporarily