mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 01:21:57 +00:00
Show progress indicator in status area
This commit is contained in:
parent
39de197e8a
commit
235987bb58
@ -728,6 +728,18 @@ struct IndexManager {
|
||||
}
|
||||
};
|
||||
|
||||
// Sends indexing progress to client.
|
||||
void EmitProgress(QueueManager* queue) {
|
||||
Out_Progress out;
|
||||
out.params.indexRequestCount = queue->index_request.Size();
|
||||
out.params.doIdMapCount = queue->do_id_map.Size();
|
||||
out.params.loadPreviousIndexCount = queue->load_previous_index.Size();
|
||||
out.params.onIdMappedCount = queue->on_id_mapped.Size();
|
||||
out.params.onIndexedCount = queue->on_indexed.Size();
|
||||
|
||||
IpcManager::instance()->SendOutMessageToClient(IpcId::Cout, out);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1131,6 +1143,8 @@ WorkThread::Result IndexMain(Config* config,
|
||||
WorkingFiles* working_files,
|
||||
MultiQueueWaiter* waiter,
|
||||
QueueManager* queue) {
|
||||
EmitProgress(queue);
|
||||
|
||||
// TODO: dispose of index after it is not used for a while.
|
||||
clang::Index index(1, 0);
|
||||
|
||||
@ -1174,6 +1188,8 @@ bool QueryDb_ImportMain(Config* config,
|
||||
ImportManager* import_manager,
|
||||
QueueManager* queue,
|
||||
WorkingFiles* working_files) {
|
||||
EmitProgress(queue);
|
||||
|
||||
bool did_work = false;
|
||||
|
||||
while (true) {
|
||||
|
@ -1654,6 +1654,25 @@ void Reflect(TVisitor& visitor, Out_ShowLogMessage& value) {
|
||||
REFLECT_MEMBER_END();
|
||||
}
|
||||
|
||||
struct Out_Progress : public lsOutMessage<Out_Progress> {
|
||||
struct Params {
|
||||
int indexRequestCount = 0;
|
||||
int doIdMapCount = 0;
|
||||
int loadPreviousIndexCount = 0;
|
||||
int onIdMappedCount = 0;
|
||||
int onIndexedCount = 0;
|
||||
};
|
||||
std::string method = "$cquery/progress";
|
||||
Params params;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_Progress::Params,
|
||||
indexRequestCount,
|
||||
doIdMapCount,
|
||||
loadPreviousIndexCount,
|
||||
onIdMappedCount,
|
||||
onIndexedCount);
|
||||
MAKE_REFLECT_STRUCT(Out_Progress, jsonrpc, method, params);
|
||||
|
||||
struct Out_CquerySetInactiveRegion
|
||||
: public lsOutMessage<Out_CquerySetInactiveRegion> {
|
||||
struct Params {
|
||||
|
@ -3,14 +3,12 @@
|
||||
#include <optional.h>
|
||||
#include "work_thread.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
|
||||
using std::experimental::nullopt;
|
||||
using std::experimental::optional;
|
||||
|
||||
@ -66,6 +64,12 @@ struct ThreadedQueue : public BaseThreadQueue {
|
||||
|
||||
explicit ThreadedQueue(MultiQueueWaiter* waiter) : waiter_(waiter) {}
|
||||
|
||||
// Returns the number of elements in the queue. This acquires a lock.
|
||||
size_t Size() const {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
return priority_.size() + queue_.size();
|
||||
}
|
||||
|
||||
// Add an element to the front of the queue.
|
||||
void PriorityEnqueue(T&& t) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
Loading…
Reference in New Issue
Block a user