mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-10 02:02:12 +00:00
Correct pending_threads counter.
Correct exit criteria in LaunchStdin.
This commit is contained in:
parent
998a1cf17f
commit
69d2e8338b
@ -423,6 +423,7 @@ void ThreadLeave() {
|
||||
std::lock_guard lock(thread_mtx);
|
||||
if (!--pending_threads)
|
||||
no_pending_threads.notify_one();
|
||||
assert(pending_threads >= 0);
|
||||
}
|
||||
|
||||
void Init() {
|
||||
@ -526,13 +527,13 @@ void LaunchStdin() {
|
||||
ReflectMember(reader, "method", method);
|
||||
if (method.empty())
|
||||
continue;
|
||||
const auto should_exit = method == "exit";
|
||||
// g_config is not available before "initialize". Use 0 in that case.
|
||||
on_request->PushBack(
|
||||
{id, std::move(method), std::move(message), std::move(document),
|
||||
chrono::steady_clock::now() +
|
||||
chrono::milliseconds(g_config ? g_config->request.timeout : 0)});
|
||||
|
||||
if (method == "exit")
|
||||
if (should_exit)
|
||||
break;
|
||||
}
|
||||
}).detach();
|
||||
|
@ -406,6 +406,10 @@ void BuildPreamble(Session &session, CompilerInvocation &CI,
|
||||
|
||||
void *PreambleMain(void *manager_) {
|
||||
auto *manager = static_cast<SemaManager *>(manager_);
|
||||
pipeline::ThreadEnter();
|
||||
struct RAII {
|
||||
~RAII() { pipeline::ThreadLeave(); }
|
||||
} raii{};
|
||||
set_thread_name("preamble");
|
||||
while (true) {
|
||||
SemaManager::PreambleTask task = manager->preamble_tasks.Dequeue();
|
||||
@ -432,12 +436,15 @@ void *PreambleMain(void *manager_) {
|
||||
manager->ScheduleDiag(task.path, debounce);
|
||||
}
|
||||
}
|
||||
pipeline::ThreadLeave();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *CompletionMain(void *manager_) {
|
||||
auto *manager = static_cast<SemaManager *>(manager_);
|
||||
pipeline::ThreadEnter();
|
||||
struct RAII {
|
||||
~RAII() { pipeline::ThreadLeave(); }
|
||||
} raii{};
|
||||
set_thread_name("comp");
|
||||
while (true) {
|
||||
std::unique_ptr<SemaManager::CompTask> task = manager->comp_tasks.Dequeue();
|
||||
@ -493,7 +500,6 @@ void *CompletionMain(void *manager_) {
|
||||
|
||||
task->on_complete(&Clang->getCodeCompletionConsumer());
|
||||
}
|
||||
pipeline::ThreadLeave();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -527,6 +533,10 @@ void printDiag(llvm::raw_string_ostream &OS, const DiagBase &d) {
|
||||
|
||||
void *DiagnosticMain(void *manager_) {
|
||||
auto *manager = static_cast<SemaManager *>(manager_);
|
||||
pipeline::ThreadEnter();
|
||||
struct RAII {
|
||||
~RAII() { pipeline::ThreadLeave(); }
|
||||
} raii{};
|
||||
set_thread_name("diag");
|
||||
while (true) {
|
||||
SemaManager::DiagTask task = manager->diag_tasks.Dequeue();
|
||||
@ -643,7 +653,6 @@ void *DiagnosticMain(void *manager_) {
|
||||
}
|
||||
manager->on_diagnostic_(task.path, ls_diags);
|
||||
}
|
||||
pipeline::ThreadLeave();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user