Skip to content

Commit

Permalink
[GEF] Slow the rate at which the AutoexposeHelper is polled to reduce…
Browse files Browse the repository at this point in the history
… CPU usage

- See eclipse/gef-classic#492
  • Loading branch information
Phillipus committed Jul 29, 2024
1 parent a6cfa31 commit 24522ad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions org.eclipse.gef/src/org/eclipse/gef/tools/TargetingTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
import java.util.Collection;
import java.util.Collections;

import org.eclipse.swt.widgets.Display;

import org.eclipse.draw2d.geometry.Point;

import org.eclipse.gef.AutoexposeHelper;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.TargetRequest;
import org.eclipse.swt.widgets.Display;

/**
* The base implementation for tools which perform targeting of editparts.
Expand Down Expand Up @@ -93,7 +91,11 @@ protected void doAutoexpose() {
return;
if (exposeHelper.step(getLocation())) {
handleAutoexpose();
Display.getCurrent().asyncExec(new QueuedAutoexpose());
// Reduce the rate at which the AutoexposeHelper is polled to reduce CPU usage.
// A value of 1 or 2 ms is enough.
// See https://github.com/eclipse/gef-classic/issues/492
Display.getCurrent().timerExec(1, new QueuedAutoexpose());
//Display.getCurrent().asyncExec(new QueuedAutoexpose());
} else
setAutoexposeHelper(null);
}
Expand Down

0 comments on commit 24522ad

Please sign in to comment.