clang-tools  14.0.0git
Public Types | Public Member Functions | List of all members
clang::clangd::TUScheduler::ASTCache Class Reference

An LRU cache of idle ASTs. More...

Public Types

using Key = const ASTWorker *
 

Public Member Functions

 ASTCache (unsigned MaxRetainedASTs)
 
std::size_t getUsedBytes (Key K)
 Returns result of getUsedBytes() for the AST cached by K. More...
 
void put (Key K, std::unique_ptr< ParsedAST > V)
 Store the value in the pool, possibly removing the last used AST. More...
 
llvm::Optional< std::unique_ptr< ParsedAST > > take (Key K, const trace::Metric *AccessMetric=nullptr)
 Returns the cached value for K, or llvm::None if the value is not in the cache anymore. More...
 

Detailed Description

An LRU cache of idle ASTs.

Because we want to limit the overall number of these we retain, the cache owns ASTs (and may evict them) while their workers are idle. Workers borrow ASTs when active, and return them when done.

Definition at line 113 of file TUScheduler.cpp.

Member Typedef Documentation

◆ Key

using clang::clangd::TUScheduler::ASTCache::Key = const ASTWorker *

Definition at line 115 of file TUScheduler.cpp.

Constructor & Destructor Documentation

◆ ASTCache()

clang::clangd::TUScheduler::ASTCache::ASTCache ( unsigned  MaxRetainedASTs)
inline

Definition at line 117 of file TUScheduler.cpp.

Member Function Documentation

◆ getUsedBytes()

std::size_t clang::clangd::TUScheduler::ASTCache::getUsedBytes ( Key  K)
inline

Returns result of getUsedBytes() for the AST cached by K.

If no AST is cached, 0 is returned.

Definition at line 121 of file TUScheduler.cpp.

References K.

◆ put()

void clang::clangd::TUScheduler::ASTCache::put ( Key  K,
std::unique_ptr< ParsedAST V 
)
inline

Store the value in the pool, possibly removing the last used AST.

The value should not be in the pool when this function is called.

Definition at line 131 of file TUScheduler.cpp.

References K.

◆ take()

llvm::Optional<std::unique_ptr<ParsedAST> > clang::clangd::TUScheduler::ASTCache::take ( Key  K,
const trace::Metric AccessMetric = nullptr 
)
inline

Returns the cached value for K, or llvm::None if the value is not in the cache anymore.

If nullptr was cached for K, this function will return a null unique_ptr wrapped into an optional. If AccessMetric is set records whether there was a hit or miss.

Definition at line 151 of file TUScheduler.cpp.

References K.


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