Skip to content

Threaded client message reader - #171

Open
oisanjaya wants to merge 5 commits into
genericptr:trunkfrom
oisanjaya:threaded_reader
Open

oisanjaya wants to merge 5 commits into
genericptr:trunkfrom
oisanjaya:threaded_reader

Conversation

@oisanjaya

Copy link
Copy Markdown
Contributor

I am trying to enable CheckSyntax in TDidChangeTextDocument.Process() like Michael do, but the problem is RunMessageLoop() read stdio synchronously so when we type into a file rapidly "asdf", for example, here's what currently happen:

  • client sent textDocument/didChange (identifier "a")
  • pasls read input buffer
  • CheckSyntax() run (take a long time)
  • before CheckSyntax() return client already sent textDocument/didChange (identifier "as"), pasls still busy, not read
  • before CheckSyntax() return client already sent textDocument/didChange (identifier "asd"), pasls still busy, not read
  • before CheckSyntax() return client already sent textDocument/didChange (identifier "asdf"), pasls still busy, not read
  • CheckSyntax() return with 'unknown identifer: "a"'
  • pasls read input buffer textDocument/didChange (identifier "as")
  • CheckSyntax() run (take a long time)
  • CheckSyntax() return with 'unknown identifer: "as"'
  • pasls read input buffer textDocument/didChange (identifier "asd")
  • ...and so on

For larger codebase like Lazarus current mechanism effectively hangs pasls.

This PR factor out task of reading stdio into separate thread. That thread queue incoming message into shared TJSONSignaledQueue. RunMessageLoop() in main thread wait for shared TJSONSignaledQueue to be ready to read.

Shared RequestQueue: TJSONSignaledQueue also debounced textDocument/didChange notification message that only last notification in queue will be consumed by pasls, hence only run CheckSyntax on latest change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant