Utilize request queue
Currently, we simply process requests (or commands) immediately as they come in, work through them completely, and then return the result. We should look into turning this into some sort of queue system.
When the client requests that a folder be indexed, we should probably push a "folder index" request to the queue, on which we won't actually index the folder, but scan the files inside it that need indexing and push those on the queue instead. This way, each file index is a separate queue item (this splits a long running task up into smaller tasks, see also prioritizing below).
This will bring us the following advantages:
- No longer need to call handleWrite() manually in
JsonRpcConnectionHandler
when we're stuck in a long indexing loop that never yields control to React so it can actually write indexing progress data. As a hack, we're currently manually invoking the write, but it seems the appropriate methods have disappeared in reactphp/socket 0.8.0, so we can't update until we change this behavior. - Ability to prioritize requests. If each folder index is split up into smaller file indexing actions, we can give priority to requests for type deduction, code completion, etc. when they come up. This would fix the issue where clients are denied service once an expensive index prune or operation starts. (In the longer run, we also need to be able to guarantee a somewhat decent response time for #91 (closed).)
- This will make it easier to implement #44 (closed), as we only need to push modified files to the queue.
Edited by Gert