Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@andfoy
Copy link
Contributor

@andfoy andfoy commented May 5, 2020

Fixes #793

@rwols
Copy link
Contributor

rwols commented May 6, 2020

I don't know if this is an improvement. You seem to have added a busy-while-loop. Study condition objects to remove that busy-while-loop.

That said, why not put access to documents, and mutation of documents, under a simple threading.Lock? clangd applies this idea and it works fine:

https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clangd/DraftStore.h
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clangd/DraftStore.cpp

@andfoy
Copy link
Contributor Author

andfoy commented May 6, 2020

@rwols We didn't took Locks on this one, as handling them may lead to deadlocks or livelocks. The implementation here is equivalent to actors and processes, as they are implemented on Erlang. We use a queue as a mailbox to send a message and then wait for the response, this way, we ensure that no process gets a deadlock

@rwols
Copy link
Contributor

rwols commented May 6, 2020

If you ensure a lock is only used from within the methods of a class like a DraftStore, and you make sure that class doesn't call its own methods, then I don't know how one would cause a deadlock.

@andfoy
Copy link
Contributor Author

andfoy commented May 6, 2020

Actually, acquiring a lock is equivalent in some sort of sense to wait for a message to arrive. Also, by using Actors, we don't have shared state anymore, this any other process cannot modify values directly without passing through the actor. Coming from the Erlang world, it seems more reasonable to use Actors and messages for handling concurrency, rather than locks or semaphores

@rwols
Copy link
Contributor

rwols commented May 6, 2020

by using Actors, we don't have shared state anymore, this any other process cannot modify values directly without passing through the actor.

All I see is an extra threading.Thread for no real reason, and a busy while loop.
The queue.Queue makes use a threading.Condition and threading.Lock, so this seems like using a lock with extra unnecessary steps.

@ccordoba12
Copy link
Contributor

@rwols, if you disagree with @andfoy and can provide the implementation you'd like to see, you're welcome to open a new PR about it. Otherwise we'll go with his.

@rwols
Copy link
Contributor

rwols commented May 6, 2020

I can only give advice. I don't have the time to delve into more open-source codebases. I fear that the unnecessary complexity will not make pyls easier to maintain. But you are of course free to merge this.

@ccordoba12 ccordoba12 added this to the 1.0.0 milestone May 10, 2020
@ccordoba12
Copy link
Contributor

@andfoy, please solve the merge conflicts in this PR.

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.

Application of incremental text changes is not atomic?

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.