/*
- * Copyright 2012 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.
#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 {
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();
// 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_ */
-