(wangle) fix after-delete assert
[folly.git] / folly / ThreadCachedArena.h
index 8e9f0aef7915a7e4e78b003e82f1e41ee326a7b2..2a5dbc30e14808ce6ab08c905bfe42bc960de97f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
 #include <limits>
 #include <boost/intrusive/slist.hpp>
 
-#include "folly/Likely.h"
-#include "folly/Arena.h"
-#include "folly/ThreadLocal.h"
+#include <folly/Likely.h>
+#include <folly/Arena.h>
+#include <folly/ThreadLocal.h>
 
 namespace folly {
 
@@ -42,7 +42,8 @@ namespace folly {
 class ThreadCachedArena {
  public:
   explicit ThreadCachedArena(
-      size_t minBlockSize = SysArena::kDefaultMinBlockSize);
+      size_t minBlockSize = SysArena::kDefaultMinBlockSize,
+      size_t maxAlign = SysArena::kDefaultMaxAlign);
 
   void* allocate(size_t size) {
     SysArena* arena = arena_.get();
@@ -69,13 +70,16 @@ class ThreadCachedArena {
   // the ThreadCachedArena is destroyed.
   void zombify(SysArena&& arena);
 
-  size_t minBlockSize_;
+  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
 };
 
+template <>
+struct IsArenaAllocator<ThreadCachedArena> : std::true_type { };
+
 }  // namespace folly
 
 #endif /* FOLLY_THREADCACHEDARENA_H_ */
-