clang-tools  14.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>

Collaboration diagram for clang::clangd::DebouncePolicy:
Collaboration graph
[legend]

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. More...
 

Static Public Member Functions

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

Public Attributes

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

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

References Max, Min, RebuildRatio, and Target.

◆ fixed()

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

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

Definition at line 1671 of file TUScheduler.cpp.

References Max, and Min.

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: