X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FThreadCachedArena.h;h=1fafe3f9dd92dd62282b52696328166899a4dfd6;hb=ad2f228ab1359952d37acdc4f3032e1405cca221;hp=2a5dbc30e14808ce6ab08c905bfe42bc960de97f;hpb=546bd3f5f2ed1fdf3a0f5c2b6737a20c4bc2f561;p=folly.git diff --git a/folly/ThreadCachedArena.h b/folly/ThreadCachedArena.h index 2a5dbc30..1fafe3f9 100644 --- a/folly/ThreadCachedArena.h +++ b/folly/ThreadCachedArena.h @@ -1,5 +1,5 @@ /* - * Copyright 2014 Facebook, Inc. + * Copyright 2016 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,16 +14,13 @@ * limitations under the License. */ -#ifndef FOLLY_THREADCACHEDARENA_H_ -#define FOLLY_THREADCACHEDARENA_H_ +#pragma once -#include -#include -#include -#include +#include -#include #include +#include +#include #include namespace folly { @@ -54,11 +51,16 @@ class ThreadCachedArena { return arena->allocate(size); } - void deallocate(void* p) { + void deallocate(void* /* p */) { // 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,14 +74,14 @@ class ThreadCachedArena { const size_t minBlockSize_; const size_t maxAlign_; - SysArena zombies_; // allocated from threads that are now dead - std::mutex zombiesMutex_; - ThreadLocalPtr arena_; // per-thread arena + + ThreadLocalPtr arena_; // Per-thread arena. + + // Allocations from threads that are now dead. + Synchronized zombies_; }; template <> struct IsArenaAllocator : std::true_type { }; } // namespace folly - -#endif /* FOLLY_THREADCACHEDARENA_H_ */