clang-tools 10.0.0

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

## Member Typedef Documentation

## ◆ Key

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

Definition at line 89 of file TUScheduler.cpp.

## Constructor & Destructor Documentation

## ◆ ASTCache()

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

Definition at line 91 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 95 of file TUScheduler.cpp.

## ◆ 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 105 of file TUScheduler.cpp.

## ◆ take()

llvm::Optional<std::unique_ptr<ParsedAST> > clang::clangd::TUScheduler::ASTCache::take | ( | Key | K | ) |
| 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.

Definition at line 123 of file TUScheduler.cpp.

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

- TUScheduler.cpp