Bug 1830206 - Fix an overly restrictive assertion in the SPSC ringbuffer. r=alwu

Differential Revision: https://phabricator.services.mozilla.com/D177770
This commit is contained in:
Paul Adenot 2023-05-24 13:11:46 +00:00
Родитель 3e3da912c0
Коммит b29794e7cc
1 изменённых файлов: 3 добавлений и 5 удалений

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

@ -103,13 +103,11 @@ class SPSCRingBufferBase {
*/
explicit SPSCRingBufferBase(int aCapacity)
: mReadIndex(0),
mWriteIndex(0)
mWriteIndex(0),
/* One more element to distinguish from empty and full buffer. */
,
mCapacity(aCapacity + 1) {
MOZ_ASSERT(StorageCapacity() < std::numeric_limits<int>::max() / 2,
"buffer too large for the type of index used.");
MOZ_ASSERT(mCapacity > 0 && aCapacity != std::numeric_limits<int>::max());
MOZ_RELEASE_ASSERT(aCapacity != std::numeric_limits<int>::max());
MOZ_RELEASE_ASSERT(mCapacity > 0);
mData = std::make_unique<T[]>(StorageCapacity());