Skip to content

Commit

Permalink
Avoid unnecessary lock on UI thread with no model listeners #3251
Browse files Browse the repository at this point in the history
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 27, 2024
1 parent 4eebe72 commit da7fed8
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ 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() {
synchronized (modelListeners) {
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 da7fed8

Please sign in to comment.