proxygen
|
#include <boost/intrusive/list.hpp>
#include <folly/ScopeGuard.h>
#include <folly/ThreadLocal.h>
#include <folly/detail/Singleton.h>
#include <folly/functional/Invoke.h>
Go to the source code of this file.
Classes | |
class | folly::SingletonThreadLocal< T, Tag, Make, TLTag > |
struct | folly::SingletonThreadLocal< T, Tag, Make, TLTag >::Node |
struct | folly::SingletonThreadLocal< T, Tag, Make, TLTag >::Wrapper |
Namespaces | |
folly | |
—— Concurrent Priority Queue Implementation —— | |
Macros | |
#define | FOLLY_DECLARE_REUSED(name, ...) |
#define FOLLY_DECLARE_REUSED | ( | name, | |
... | |||
) |
FOLLY_DECLARE_REUSED
Useful for local variables of container types, where it is desired to avoid the overhead associated with the local variable entering and leaving scope. Rather, where it is desired that the memory be reused between invocations of the same scope in the same thread rather than deallocated and reallocated between invocations of the same scope in the same thread. Note that the container will always be cleared between invocations; it is only the backing memory allocation which is reused.
Example:
void traverse_perform(int root); template <typename f>=""> void traverse_each_child_r(int root, F const&); void traverse_depthwise(int root) { // preserves some of the memory backing these per-thread data structures FOLLY_DECLARE_REUSED(seen, std::unordered_set<int>); FOLLY_DECLARE_REUSED(work, std::vector<int>); // example algorithm that uses these per-thread data structures work.push_back(root); while (!work.empty()) { root = work.back(); work.pop_back(); seen.insert(root); traverse_perform(root); traverse_each_child_r(root, [&](int item) { if (!seen.count(item)) { work.push_back(item); } }); } }
Definition at line 205 of file SingletonThreadLocal.h.
Referenced by TEST().