Extract Reconciler Job Into an own class #3088
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the
BackgroundThreadis an inner class of theAbstractReconcilerand is tightly coupled with it what makes it quite hard to understand the interaction between both and to properly update a reconciler on document changes or refactor the code.This is a first attempt to decouple the things by extracting the inner class in an own (package private) type to allow further refactoring operations and proper encapsulation.
Whats next:
Currently the change of the viewer initiates an exchange of the reconcile queue, this might or might not overlap with the background thread and the Job itself is not changed making it also not possible to identify the actual document. Instead the viewer and the queue should be passed in the constructor, the old job should be canceled and a new one must be scheduled to make this properly works. With that it would even be possible to find out the document providing input and set the name accordingly making the whole access to the shared data more threadsafe and easier to understand.
Then at the moment the job uses delays to wait for more things to do and sleeping otherwise unless notified. This notification for new things could be replaced by a scheduling of the job instead making much less threads running when many documents are open. Currently for each open Editor one thread is running forever unless the user closes the document.