ThreadLocalDetail: fix bug just introduced w/ recent change to constexpr-ctor style...
[folly.git] / folly / ThreadCachedArena.h
index ff1eb8fd076c9dea457baf1a951d81881d71c6cb..e34a618dfa4b41f86cf5ecfe99de26f86e3587ff 100644 (file)
 #ifndef FOLLY_THREADCACHEDARENA_H_
 #define FOLLY_THREADCACHEDARENA_H_
 
-#include <utility>
-#include <mutex>
-#include <limits>
-#include <boost/intrusive/slist.hpp>
+#include <type_traits>
 
-#include <folly/Likely.h>
 #include <folly/Arena.h>
+#include <folly/Likely.h>
+#include <folly/Synchronized.h>
 #include <folly/ThreadLocal.h>
 
 namespace folly {
@@ -58,7 +56,12 @@ class ThreadCachedArena {
     // Deallocate? Never!
   }
 
+  // Gets the total memory used by the arena
+  size_t totalSize() const;
+
  private:
+  struct ThreadLocalPtrTag {};
+
   ThreadCachedArena(const ThreadCachedArena&) = delete;
   ThreadCachedArena(ThreadCachedArena&&) = delete;
   ThreadCachedArena& operator=(const ThreadCachedArena&) = delete;
@@ -72,9 +75,11 @@ class ThreadCachedArena {
 
   const size_t minBlockSize_;
   const size_t maxAlign_;
-  SysArena zombies_;  // allocated from threads that are now dead
-  std::mutex zombiesMutex_;
-  ThreadLocalPtr<SysArena> arena_;  // per-thread arena
+
+  ThreadLocalPtr<SysArena, ThreadLocalPtrTag> arena_;  // Per-thread arena.
+
+  // Allocations from threads that are now dead.
+  Synchronized<SysArena> zombies_;
 };
 
 template <>