//===--- TUScheduler.h -------------------------------------------*-C++-*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H #include "ASTSignals.h" #include "Compiler.h" #include "Diagnostics.h" #include "GlobalCompilationDatabase.h" #include "clang-include-cleaner/Record.h" #include "support/Function.h" #include "support/MemoryTree.h" #include "support/Path.h" #include "support/Threading.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include <chrono> #include <memory> #include <optional> #include <string> namespace clang { namespace clangd { class ParsedAST; struct PreambleData; /// Returns a number of a default async threads to use for TUScheduler. /// Returned value is always >= 1 (i.e. will not cause requests to be processed /// synchronously). unsigned getDefaultAsyncThreadsCount(); struct InputsAndAST { … }; struct InputsAndPreamble { … }; /// Determines whether diagnostics should be generated for a file snapshot. enum class WantDiagnostics { … }; /// Configuration of the AST retention policy. This only covers retention of /// *idle* ASTs. If queue has operations requiring the AST, they might be /// kept in memory. struct ASTRetentionPolicy { … }; /// 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. struct DebouncePolicy { … }; /// PreambleThrottler controls which preambles can build at any given time. /// This can be used to limit overall concurrency, and to prioritize some /// preambles over others. /// In a distributed environment, a throttler may be able to coordinate resource /// use across several clangd instances. /// /// This class is threadsafe. class PreambleThrottler { … }; enum class PreambleAction { … }; struct ASTAction { … }; // Internal status of the TU in TUScheduler. struct TUStatus { … }; class ParsingCallbacks { … }; /// Handles running tasks for ClangdServer and managing the resources (e.g., /// preambles and ASTs) for opened files. /// TUScheduler is not thread-safe, only one thread should be providing updates /// and scheduling tasks. /// Callbacks are run on a threadpool and it's appropriate to do slow work in /// them. Each task has a name, used for tracing (should be UpperCamelCase). class TUScheduler { … }; } // namespace clangd } // namespace clang #endif