mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use more sane API for LowMemoryWatcher
This commit is contained in:
+9
-6
@@ -44,12 +44,6 @@ import java.util.*;
|
||||
public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl");
|
||||
private static final ReferenceQueue<SmartPsiElementPointerImpl> ourQueue = new ReferenceQueue<SmartPsiElementPointerImpl>();
|
||||
@SuppressWarnings("unused") private static final LowMemoryWatcher ourWatcher = LowMemoryWatcher.register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processQueue();
|
||||
}
|
||||
});
|
||||
|
||||
private final Project myProject;
|
||||
private final Key<FilePointersList> POINTERS_KEY;
|
||||
@@ -61,6 +55,15 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
POINTERS_KEY = Key.create("SMART_POINTERS for "+project);
|
||||
}
|
||||
|
||||
static {
|
||||
LowMemoryWatcher.register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processQueue();
|
||||
}
|
||||
}, ApplicationManager.getApplication());
|
||||
}
|
||||
|
||||
private static void processQueue() {
|
||||
while (true) {
|
||||
PointerReference reference = (PointerReference)ourQueue.poll();
|
||||
|
||||
@@ -49,7 +49,7 @@ class AstPathPsiMap {
|
||||
|
||||
AstPathPsiMap(@NotNull Project project) {
|
||||
MyReferenceQueue queue = project.getUserData(STUB_PSI_REFS);
|
||||
myQueue = queue != null ? queue : ((UserDataHolderEx)project).putUserDataIfAbsent(STUB_PSI_REFS, new MyReferenceQueue());
|
||||
myQueue = queue != null ? queue : ((UserDataHolderEx)project).putUserDataIfAbsent(STUB_PSI_REFS, new MyReferenceQueue(project));
|
||||
}
|
||||
|
||||
void invalidatePsi() {
|
||||
@@ -100,12 +100,14 @@ class AstPathPsiMap {
|
||||
}
|
||||
|
||||
private static class MyReferenceQueue extends ReferenceQueue<StubBasedPsiElementBase<?>> {
|
||||
@SuppressWarnings("unused") LowMemoryWatcher watcher = LowMemoryWatcher.register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
cleanupStaleReferences();
|
||||
}
|
||||
});
|
||||
MyReferenceQueue(Project project) {
|
||||
LowMemoryWatcher.register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
cleanupStaleReferences();
|
||||
}
|
||||
},project);
|
||||
}
|
||||
|
||||
void cleanupStaleReferences() {
|
||||
while (true) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class CompressedAppendableFile {
|
||||
private static final int myMinAppendBufferLength = 1024;
|
||||
|
||||
public static final String INCOMPLETE_CHUNK_LENGTH_FILE_EXTENSION = ".s";
|
||||
@SuppressWarnings("unused") private final LowMemoryWatcher myLowMemoryWatcher;
|
||||
private final LowMemoryWatcher myLowMemoryWatcher;
|
||||
|
||||
public CompressedAppendableFile(File file) {
|
||||
this(file, PersistentBTreeEnumerator.PAGE_SIZE);
|
||||
@@ -434,6 +434,7 @@ public class CompressedAppendableFile {
|
||||
}
|
||||
|
||||
public synchronized void dispose() {
|
||||
myLowMemoryWatcher.stop();
|
||||
force();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user