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
|
} // namespace
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1131,6 +1143,8 @@ WorkThread::Result IndexMain(Config* config,
|
|||||||
WorkingFiles* working_files,
|
WorkingFiles* working_files,
|
||||||
MultiQueueWaiter* waiter,
|
MultiQueueWaiter* waiter,
|
||||||
QueueManager* queue) {
|
QueueManager* queue) {
|
||||||
|
EmitProgress(queue);
|
||||||
|
|
||||||
// TODO: dispose of index after it is not used for a while.
|
// TODO: dispose of index after it is not used for a while.
|
||||||
clang::Index index(1, 0);
|
clang::Index index(1, 0);
|
||||||
|
|
||||||
@ -1174,6 +1188,8 @@ bool QueryDb_ImportMain(Config* config,
|
|||||||
ImportManager* import_manager,
|
ImportManager* import_manager,
|
||||||
QueueManager* queue,
|
QueueManager* queue,
|
||||||
WorkingFiles* working_files) {
|
WorkingFiles* working_files) {
|
||||||
|
EmitProgress(queue);
|
||||||
|
|
||||||
bool did_work = false;
|
bool did_work = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -1654,6 +1654,25 @@ void Reflect(TVisitor& visitor, Out_ShowLogMessage& value) {
|
|||||||
REFLECT_MEMBER_END();
|
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
|
struct Out_CquerySetInactiveRegion
|
||||||
: public lsOutMessage<Out_CquerySetInactiveRegion> {
|
: public lsOutMessage<Out_CquerySetInactiveRegion> {
|
||||||
struct Params {
|
struct Params {
|
||||||
|
@ -3,14 +3,12 @@
|
|||||||
#include <optional.h>
|
#include <optional.h>
|
||||||
#include "work_thread.h"
|
#include "work_thread.h"
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
|
||||||
using std::experimental::nullopt;
|
using std::experimental::nullopt;
|
||||||
using std::experimental::optional;
|
using std::experimental::optional;
|
||||||
|
|
||||||
@ -66,6 +64,12 @@ struct ThreadedQueue : public BaseThreadQueue {
|
|||||||
|
|
||||||
explicit ThreadedQueue(MultiQueueWaiter* waiter) : waiter_(waiter) {}
|
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.
|
// Add an element to the front of the queue.
|
||||||
void PriorityEnqueue(T&& t) {
|
void PriorityEnqueue(T&& t) {
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
Loading…
Reference in New Issue
Block a user