soot.jimple.infoflow.solver.executors.SetPoolExecutor 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
package soot.jimple.infoflow.solver.executors;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
/**
* Executor class that ensures that no two equal tasks are in the queue at the
* same time
*
* @author Steven Arzt
*
*/
public class SetPoolExecutor extends InterruptableExecutor {
protected Set waiting = Collections.newSetFromMap(new ConcurrentHashMap());
public SetPoolExecutor(int corePoolSize, int maximumPoolSize,
long keepAliveTime, TimeUnit unit, BlockingQueue workQueue) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
}
@Override
public void execute(Runnable command) {
// Make sure that we don't schedule a task for execution that is already
// in the queue
if (waiting.add(command))
super.execute(command);
}
@Override
protected void afterExecute(Runnable r, Throwable t) {
waiting.remove(r);
super.afterExecute(r, t);
}
@Override
public void interrupt() {
super.interrupt();
this.waiting.clear();
}
@Override
public void shutdown() {
super.shutdown();
this.waiting.clear();
}
@Override
public List shutdownNow() {
List tasks = super.shutdownNow();
this.waiting.clear();
return tasks;
}
}