9#ifndef LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_PENDINGCHANGES_H_
10#define LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_PENDINGCHANGES_H_
12#include "llvm/ADT/StringMap.h"
13#include "llvm/Support/LSP/Protocol.h"
14#include "llvm/Support/ThreadPool.h"
29 llvm::ThreadPoolStrategy s = llvm::hardware_concurrency();
30 s.ThreadsRequested = (maxThreads == 0 ? 1u : maxThreads);
48 std::vector<llvm::lsp::TextDocumentContentChangeEvent>
changes;
58 unsigned maxThreads = std::thread::hardware_concurrency())
68 void erase(llvm::StringRef key);
71 void erase(
const llvm::lsp::URIForFile &uri);
78 std::function<
void(std::unique_ptr<PendingChanges>)> cb);
82 void enqueueChange(
const llvm::lsp::DidChangeTextDocumentParams ¶ms);
88 void debounceAndThen(
const llvm::lsp::DidChangeTextDocumentParams ¶ms,
90 std::function<
void(std::unique_ptr<PendingChanges>)> cb);
97 std::unique_ptr<PendingChanges>
98 takeAndErase(llvm::StringMap<PendingChanges>::iterator it);
Thread-safe accumulator + debouncer for text document changes.
void debounceAndThen(const llvm::lsp::DidChangeTextDocumentParams ¶ms, DebounceOptions options, std::function< void(std::unique_ptr< PendingChanges >)> cb)
Schedule a debounce check on the internal pool and call cb when ready.
std::mutex mu
Guards pending.
PendingChangesMap(unsigned maxThreads=std::thread::hardware_concurrency())
llvm::ThreadPoolTaskGroup tasks
llvm::StdThreadPool pool
Internal concurrency used for sleeps + checks.
std::unique_ptr< PendingChanges > takeAndErase(llvm::StringMap< PendingChanges >::iterator it)
NOT thread-safe; caller must hold mu.
llvm::StringMap< PendingChanges > pending
Per-document edit bursts, keyed by file string.
void abort()
Call during server shutdown; Erase all file changes, then clear file map.
void enqueueChange(const llvm::lsp::DidChangeTextDocumentParams ¶ms)
Append new edits for a document key.
void debounceAndUpdate(const llvm::lsp::DidChangeTextDocumentParams ¶ms, DebounceOptions options, std::function< void(std::unique_ptr< PendingChanges >)> cb)
Append new edits for a document key, then start a debounced update thread.
void erase(llvm::StringRef key)
Remove all pending edits for a document key.
PendingChanges & getOrCreateEntry(std::string_view key)
NOT thread-safe; caller must hold mu.
static llvm::ThreadPoolStrategy makeStrategy(unsigned maxThreads)
Build a pool strategy with a sensible minimum.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Debounce tuning for document-change bursts.
uint64_t debounceMinMs
Minimum quiet time before we flush.
static DebounceOptions fromLSPOptions(const circt::lsp::LSPServerOptions &opts)
Factory: build from server options. Keep mapping 1:1 for clarity.
bool disableDebounce
If true, flush immediately (no sleep/check).
uint64_t debounceMaxMs
Maximum total burst time (0 = no cap).
Accumulated edits + timing for a single document key.
std::chrono::steady_clock::time_point firstChangeTime
std::chrono::steady_clock::time_point lastChangeTime
std::vector< llvm::lsp::TextDocumentContentChangeEvent > changes