Fixed: #1627 Previously decompiled scripts not cached

Fixed: SWF is not garbage collected on close in some situations
Fixed: AS1/2 script search does not show all results
This commit is contained in:
Jindra Petřík
2021-02-27 20:46:02 +01:00
parent e308c00601
commit 28380d1d34
12 changed files with 131 additions and 22 deletions

View File

@@ -43,18 +43,21 @@ public abstract class CancellableWorker<T> implements RunnableFuture<T> {
private static List<CancellableWorker> workers = Collections.synchronizedList(new ArrayList<CancellableWorker>());
private final FutureTask<T> future;
private FutureTask<T> future;
private static final Map<Thread, CancellableWorker> threadWorkers = Collections.synchronizedMap(new WeakHashMap<>());
private List<CancellableWorker> subWorkers = Collections.synchronizedList(new ArrayList<>());
private Thread thread;
public CancellableWorker() {
super();
Callable<T> callable = new Callable<T>() {
@Override
public T call() throws Exception {
threadWorkers.put(Thread.currentThread(), CancellableWorker.this);
thread = Thread.currentThread();
threadWorkers.put(thread, CancellableWorker.this);
return doInBackground();
}
};
@@ -130,6 +133,9 @@ public abstract class CancellableWorker<T> implements RunnableFuture<T> {
}
private void workerDone() {
if (thread != null && threadWorkers.get(thread) == this) {
threadWorkers.remove(thread);
}
workers.remove(this);
done();
}
@@ -165,4 +171,11 @@ public abstract class CancellableWorker<T> implements RunnableFuture<T> {
}
}
}
public void free() {
future = null;
for (CancellableWorker w : subWorkers) {
w.free();
}
}
}