make ThreadCache constructor/destructor private

1. This documents the intent that the way to create/destroy a ThreadCache
    object is through the static methods NewHeap()/DeleteCache()
2. It makes using the class less error prone. The compiler will complain
   if some new code is accidentally creating objects directly
3. This may allow some compilers to optimize code knowing that those
   functions are private

Signed-off-by: Olivier Langlois <olivier@trillion01.com>
This commit is contained in:
Olivier Langlois 2024-09-01 15:45:16 -04:00
parent ae15d7a490
commit f46c141b4e
1 changed files with 5 additions and 5 deletions

View File

@ -69,11 +69,6 @@ class ThreadCache {
// REQUIRES: Static::pageheap_lock is not held.
static void DeleteCache(ThreadCache* heap);
// REQUIRES: Static::pageheap_lock is held
ThreadCache();
// REQUIRES: Static::pageheap_lock is not held
~ThreadCache();
// Accessors (mostly just for printing stats)
int freelist_length(uint32_t cl) const { return list_[cl].length(); }
@ -240,6 +235,11 @@ class ThreadCache {
}
};
// REQUIRES: Static::pageheap_lock is held
ThreadCache();
// REQUIRES: Static::pageheap_lock is not held
~ThreadCache();
// Gets and returns an object from the central cache, and, if possible,
// also adds some objects of that size class to this thread cache.
void* FetchFromCentralCache(uint32_t cl, int32_t byte_size,