mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-14 22:41:53 +00:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user