Bug 1575442 - BlocksRingBuffer::LockAndRun - r=gregtatum

Some users will want to lock the buffer but not do any specific operation with
it.

Differential Revision: https://phabricator.services.mozilla.com/D42824

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2019-08-22 00:32:51 +00:00
parent 94aab56280
commit 608cb489b5

View File

@ -290,6 +290,15 @@ class BlocksRingBuffer {
std::forward<EntryDestructor>(aEntryDestructor));
}
// Lock the buffer mutex and run the provided callback.
// This can be useful when the caller needs to explicitly lock down this
// buffer, but not do anything else with it.
template <typename Callback>
auto LockAndRun(Callback&& aCallback) const {
baseprofiler::detail::BaseProfilerAutoLock lock(mMutex);
return std::forward<Callback>(aCallback)();
}
// Buffer length in bytes.
Maybe<PowerOfTwo<Length>> BufferLength() const {
baseprofiler::detail::BaseProfilerAutoLock lock(mMutex);