Skip to content

Commit

Permalink
Avoid unnecessary lock on UI thread with no model listeners eclipse-x…
Browse files Browse the repository at this point in the history
…text#3251

Avoid unnecessarily aquiring a lock on the UI thread if there are no
model listeners in the Xtext document.

Signed-off-by: Martin Jobst <[email protected]>
  • Loading branch information
mx990 committed Nov 22, 2024
1 parent 574f7c3 commit 7783fd5
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ protected <T> T internalReadOnly(IUnitOfWork<T, XtextResource> work, boolean isC
* changing while they run. To achieve this, we run the {@link IXtextModelListener}s on the UI thread.
*/
private void notifyModelListenersOnUiThread() {
if(modelListeners.isEmpty()) {
return;
}
Display display = PlatformUI.getWorkbench().getDisplay();
if (Thread.currentThread() == display.getThread()) {
// We are already running on the display thread. Run the listeners immediately.
Expand Down

0 comments on commit 7783fd5

Please sign in to comment.