clang-tools
11.0.0
|
Memoize is a cache to store and reuse computation results based on a key. More...
#include <Threading.h>
Public Member Functions | |
Memoize () | |
template<typename T , typename Func > | |
Container::mapped_type | get (T &&Key, Func Compute) const |
Memoize is a cache to store and reuse computation results based on a key.
Memoize<DenseMap<int, bool>> PrimeCache; for (int I : RepetitiveNumbers) if (PrimeCache.get(I, [&] { return expensiveIsPrime(I); })) llvm::errs() << "Prime: " << I << "\n";
The computation will only be run once for each key. This class is threadsafe. Concurrent calls for the same key may run the computation multiple times, but each call will return the same result.
Definition at line 144 of file Threading.h.
|
inline |
Definition at line 149 of file Threading.h.
|
inline |
Definition at line 152 of file Threading.h.
Referenced by clang::clangd::TEST_F().