From f46c141b4eaea3872c2bfc3974d1240ff16dd00b Mon Sep 17 00:00:00 2001 From: Olivier Langlois Date: Sun, 1 Sep 2024 15:45:16 -0400 Subject: 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 --- src/thread_cache.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/thread_cache.h b/src/thread_cache.h index 7454688..09cfcef 100644 --- a/src/thread_cache.h +++ b/src/thread_cache.h @@ -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, -- cgit v1.2.3