/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* VolatileBuffer * * This class represents a piece of memory that can potentially be reclaimed * by the OS when not in use. As long as there are one or more * VolatileBufferPtrs holding on to a VolatileBuffer, the memory will remain * available. However, when there are no VolatileBufferPtrs holding a * VolatileBuffer, the OS can purge the pages if it wants to. The OS can make * better decisions about what pages to purge than we can. * * VolatileBuffers may not always be volatile - if the allocation is too small, * or if the OS doesn't support the feature, or if the OS doesn't want to, * the buffer will be allocated on heap. * * VolatileBuffer allocations are fallible. They are intended for uses where * one may allocate large buffers for caching data. Init() must be called * exactly once. * * After getting a reference to VolatileBuffer using VolatileBufferPtr, * WasPurged() can be used to check if the OS purged any pages in the buffer. * The OS cannot purge a buffer immediately after a VolatileBuffer is * initialized. At least one VolatileBufferPtr must be created before the * buffer can be purged, so the first use of VolatileBufferPtr does not need * to check WasPurged(). * * When a buffer is purged, some or all of the buffer is zeroed out. This * API cannot tell which parts of the buffer were lost. * * VolatileBuffer and VolatileBufferPtr are threadsafe.
*/
namespace mozilla {
class VolatileBuffer { friendclass VolatileBufferPtr_base;
/** * Protects mLockCount, mFirstLock, and changes to the volatility of our * buffer. Other member variables are read-only except in Init() and the * destructor.
*/
Mutex mMutex MOZ_UNANNOTATED;
void* mBuf;
size_t mSize; int mLockCount; #ifdefined(ANDROID) int mFd; #elifdefined(XP_DARWIN) bool mHeap; #elifdefined(XP_WIN) bool mHeap; bool mFirstLock; #endif
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.