clang-tools 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::clangd::DebouncePolicy Struct Reference

Clangd may wait after an update to see if another one comes along. More...

#include <TUScheduler.h>

Public Types

using clock = std::chrono::steady_clock
 

Public Member Functions

clock::duration compute (llvm::ArrayRef< clock::duration > History) const
 Compute the time to debounce based on this policy and recent build times.
 

Static Public Member Functions

static DebouncePolicy fixed (clock::duration)
 A policy that always returns the same duration, useful for tests.
 

Public Attributes

clock::duration Min = {}
 The minimum time that we always debounce for.
 
clock::duration Max = {}
 The maximum time we may debounce for.
 
float RebuildRatio = 1
 Target debounce, as a fraction of file rebuild time.
 

Detailed Description

Clangd may wait after an update to see if another one comes along.

This is so we rebuild once the user stops typing, not when they start. Debounce may be disabled/interrupted if we must build this version. The debounce time is responsive to user preferences and rebuild time. In the future, we could also consider different types of edits.

Definition at line 74 of file TUScheduler.h.

Member Typedef Documentation

◆ clock

using clang::clangd::DebouncePolicy::clock = std::chrono::steady_clock

Definition at line 75 of file TUScheduler.h.

Member Function Documentation

◆ compute()

DebouncePolicy::clock::duration clang::clangd::DebouncePolicy::compute ( llvm::ArrayRef< clock::duration >  History) const

Compute the time to debounce based on this policy and recent build times.

Definition at line 1833 of file TUScheduler.cpp.

References Max, Min, and RebuildRatio.

◆ fixed()

DebouncePolicy clang::clangd::DebouncePolicy::fixed ( clock::duration  T)
static

A policy that always returns the same duration, useful for tests.

Definition at line 1854 of file TUScheduler.cpp.

References Max, and Min.

Referenced by clang::clangd::ClangdServer::optsForTest().

Member Data Documentation

◆ Max

clock::duration clang::clangd::DebouncePolicy::Max = {}

The maximum time we may debounce for.

Definition at line 80 of file TUScheduler.h.

Referenced by compute(), and fixed().

◆ Min

clock::duration clang::clangd::DebouncePolicy::Min = {}

The minimum time that we always debounce for.

Definition at line 78 of file TUScheduler.h.

Referenced by compute(), and fixed().

◆ RebuildRatio

float clang::clangd::DebouncePolicy::RebuildRatio = 1

Target debounce, as a fraction of file rebuild time.

e.g. RebuildRatio = 2, recent builds took 200ms => debounce for 400ms.

Definition at line 83 of file TUScheduler.h.

Referenced by compute().


The documentation for this struct was generated from the following files: