mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't call "dispose" on each execution in case of compound callback
This commit is contained in:
@@ -63,8 +63,9 @@ public class ActionCallback implements Disposable {
|
||||
}
|
||||
|
||||
public void setDone() {
|
||||
myDone.setExecuted();
|
||||
Disposer.dispose(this);
|
||||
if (myDone.setExecuted()) {
|
||||
Disposer.dispose(this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
@@ -80,8 +81,9 @@ public class ActionCallback implements Disposable {
|
||||
}
|
||||
|
||||
public void setRejected() {
|
||||
myRejected.setExecuted();
|
||||
Disposer.dispose(this);
|
||||
if (myRejected.setExecuted()) {
|
||||
Disposer.dispose(this);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -37,23 +37,26 @@ class ExecutionCallback {
|
||||
myCountToExecution = executedCount;
|
||||
}
|
||||
|
||||
void setExecuted() {
|
||||
boolean setExecuted() {
|
||||
signalExecution();
|
||||
if (isExecuted()) {
|
||||
Runnable[] all;
|
||||
synchronized (this) {
|
||||
if (myRunnables == null) {
|
||||
all = ArrayUtil.EMPTY_RUNNABLE_ARRAY;
|
||||
}
|
||||
else {
|
||||
all = myRunnables.toArray(new Runnable[myRunnables.size()]);
|
||||
myRunnables.clear();
|
||||
}
|
||||
if (!isExecuted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Runnable[] all;
|
||||
synchronized (this) {
|
||||
if (myRunnables == null) {
|
||||
all = ArrayUtil.EMPTY_RUNNABLE_ARRAY;
|
||||
}
|
||||
for (Runnable each : all) {
|
||||
each.run();
|
||||
else {
|
||||
all = myRunnables.toArray(new Runnable[myRunnables.size()]);
|
||||
myRunnables.clear();
|
||||
}
|
||||
}
|
||||
for (Runnable each : all) {
|
||||
each.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class CompositeRunnable extends ArrayList<Runnable> implements Runnable {
|
||||
|
||||
Reference in New Issue
Block a user