mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
sema_manager: only keep latest session.maxNum sessions in case of a surge of textDocument/didChange
This commit is contained in:
parent
3ce756e39a
commit
5a48e6c419
@ -421,7 +421,8 @@ void *preambleMain(void *manager_) {
|
||||
auto *manager = static_cast<SemaManager *>(manager_);
|
||||
set_thread_name("preamble");
|
||||
while (true) {
|
||||
SemaManager::PreambleTask task = manager->preamble_tasks.dequeue();
|
||||
SemaManager::PreambleTask task = manager->preamble_tasks.dequeue(
|
||||
g_config ? g_config->session.maxNum : 0);
|
||||
if (pipeline::g_quit.load(std::memory_order_relaxed))
|
||||
break;
|
||||
|
||||
|
@ -126,12 +126,14 @@ public:
|
||||
bool isEmpty() { return total_count_ == 0; }
|
||||
|
||||
// Get the first element from the queue. Blocks until one is available.
|
||||
T dequeue() {
|
||||
T dequeue(int keep_only_latest = 0) {
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
waiter_->cv.wait(lock,
|
||||
[&]() { return !priority_.empty() || !queue_.empty(); });
|
||||
|
||||
auto execute = [&](std::deque<T> *q) {
|
||||
if (keep_only_latest > 0 && q->size() > keep_only_latest)
|
||||
q->erase(q->begin(), q->end() - keep_only_latest);
|
||||
auto val = std::move(q->front());
|
||||
q->pop_front();
|
||||
--total_count_;
|
||||
|
Loading…
Reference in New Issue
Block a user