Bug 1635338 - ProfileChunkedBuffer::IsThreadSafeAndLockedOnCurrentThread - r=gregtatum,canaltinova

Expose `ProfileChunkedBuffer`'s mutex (if present), so that potential callers can avoid recursive calls that would lock or crash.

Differential Revision: https://phabricator.services.mozilla.com/D73788
This commit is contained in:
Gerald Squelart 2020-05-06 12:44:44 +00:00
Родитель f504b757de
Коммит a58e3ee5a8
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -587,6 +587,13 @@ class ProfileChunkedBuffer {
return {mRangeStart, mRangeEnd, mPushedBlockCount, mClearedBlockCount};
}
// True if this buffer is already locked on this thread.
// This should be used if some functions may call an already-locked buffer,
// e.g.: Put -> memory hook -> profiler_add_native_allocation_marker -> Put.
[[nodiscard]] bool IsThreadSafeAndLockedOnCurrentThread() const {
return mMutex.IsActivatedAndLockedOnCurrentThread();
}
// 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.