matthiasblaesing commented on a change in pull request #3153:
URL: https://github.com/apache/netbeans/pull/3153#discussion_r704678192



##########
File path: ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java
##########
@@ -432,14 +447,19 @@ public void runOnBackground(Runnable r) {
     }
 
     private static void scheduleBackgroundTask(RequestProcessor.Task req) {
-        WORKER.post(req, DELAY);
+        synchronized(WORKER_SCHEDULED) {
+            if(! WORKER_SCHEDULED.containsKey(req)) {
+                WORKER_SCHEDULED.put(req, null);
+                WORKER.post(req, DELAY);

Review comment:
       I think the behavior of my proposed solution and the your suggestion is 
slightly different. 
   
   From my observation (and my reading of the documentation of 
RequestProcessor), with RequestProcessor.Task#schedule, if an event occurs 
inside the 500ms timeframe, the execution of the background update will be 
postponed again for 500ms, if the the next event happens inside this 500ms 
frame, updates will be postponed again and so on. So the view is only updated, 
once the user stops changing things.
   
   My solution would update after 500ms and again 500ms later.
   
   I observed the behavior of the java editor and at least the navigator 
windows follows the principle described for RequestProcessor.Task#schedule and 
I never had a problem with that. 500ms seem to be short enough to be a good 
balance between wait time and resource usage.
   
   I updated this PR accordingly.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to