mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
platform: do not keep CheckedDisposable-s in disposed object weak-key map. It should allow to fix Disposer-s performance problems on client side (when Disposer.register/dispose triggered very often) IDEA-314139
GitOrigin-RevId: 9d0ca9cc3e1a7ff92971e97cb6ce73cfa225c26b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f35952b792
commit
baed10e426
+9
-2
@@ -26,6 +26,7 @@ import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.project.impl.ProjectImpl;
|
||||
import com.intellij.openapi.util.CheckedDisposable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -272,10 +273,16 @@ public final class NonBlockingReadActionImpl<T> implements NonBlockingReadAction
|
||||
cancel();
|
||||
break;
|
||||
}
|
||||
//noinspection Convert2Lambda,Anonymous2MethodRef
|
||||
Disposable child = new Disposable() { // not a lambda to create a separate object for each parent
|
||||
Disposable child = new CheckedDisposable() {
|
||||
private volatile boolean disposed;
|
||||
@Override
|
||||
public boolean isDisposed() {
|
||||
return disposed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
disposed = true;
|
||||
cancel();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -79,6 +79,9 @@ final class ObjectTree {
|
||||
}
|
||||
}
|
||||
boolean isDisposed(@NotNull Disposable object) {
|
||||
if (object instanceof CheckedDisposable) {
|
||||
return ((CheckedDisposable)object).isDisposed();
|
||||
}
|
||||
synchronized (getTreeLock()) {
|
||||
return myDisposedObjects.get(object) != null;
|
||||
}
|
||||
@@ -231,6 +234,9 @@ final class ObjectTree {
|
||||
|
||||
// return old value
|
||||
Throwable rememberDisposedTrace(@NotNull Disposable object, @Nullable Throwable trace) {
|
||||
if (object instanceof CheckedDisposable) {
|
||||
return null;
|
||||
}
|
||||
return myDisposedObjects.put(object, ObjectUtils.notNull(trace, UNKNOWN_TRACE));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user