clang-tools  14.0.0git
Public Member Functions | List of all members
clang::clangd::Memoize< Container > Class Template Reference

Memoize is a cache to store and reuse computation results based on a key. More...

#include <Threading.h>

Inheritance diagram for clang::clangd::Memoize< Container >:
Inheritance graph
[legend]

Public Member Functions

 Memoize ()
 
template<typename T , typename Func >
Container::mapped_type get (T &&Key, Func Compute) const
 

Detailed Description

template<typename Container>
class clang::clangd::Memoize< Container >

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 145 of file Threading.h.

Constructor & Destructor Documentation

◆ Memoize()

template<typename Container >
clang::clangd::Memoize< Container >::Memoize ( )
inline

Definition at line 150 of file Threading.h.

Member Function Documentation

◆ get()

template<typename Container >
template<typename T , typename Func >
Container::mapped_type clang::clangd::Memoize< Container >::get ( T &&  Key,
Func  Compute 
) const
inline

Definition at line 153 of file Threading.h.


The documentation for this class was generated from the following file: