soot.jimple.infoflow.solver.fastSolver.LocalWorklistTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of soot-infoflow Show documentation
Show all versions of soot-infoflow Show documentation
Soot extending data flow tracking components for Java
The newest version!
package soot.jimple.infoflow.solver.fastSolver;
import java.util.ArrayDeque;
/**
* This special task may run multiple tasks on the same thread if they are
* scheduled using {@link #scheduleLocal(Runnable)}
*
* @author Marc Miltenberger
*/
public abstract class LocalWorklistTask implements Runnable {
private ArrayDeque localTaskList = new ArrayDeque<>();
private static final ThreadLocal TASKS = new ThreadLocal<>();
@Override
public final void run() {
try {
ArrayDeque list = localTaskList;
list.add(this);
TASKS.set(this);
while (true) {
Runnable d = list.poll();
if (d == null)
break;
if (d instanceof LocalWorklistTask) {
LocalWorklistTask l = (LocalWorklistTask) d;
l.runInternal();
} else
d.run();
}
} finally {
TASKS.remove();
}
}
public abstract void runInternal();
public static void scheduleLocal(Runnable task) {
LocalWorklistTask t = TASKS.get();
if (t != null)
t.localTaskList.add(task);
}
}