clang-tools 19.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.
 
void put (Key K, std::unique_ptr< ParsedAST > V)
 Store the value in the pool, possibly removing the last used AST.
 
std::optional< std::unique_ptr< ParsedAST > > take (Key K, const trace::Metric *AccessMetric=nullptr)
 Returns the cached value for K, or std::nullopt if the value is not in the cache anymore.
 

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 151 of file TUScheduler.cpp.

Member Typedef Documentation

◆ Key

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

Definition at line 153 of file TUScheduler.cpp.

Constructor & Destructor Documentation

◆ ASTCache()

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

Definition at line 155 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 159 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 169 of file TUScheduler.cpp.

References K.

◆ take()

std::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 std::nullopt 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 189 of file TUScheduler.cpp.

References K.


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