
org.umlg.runtime.util.TinkerClassifierBehaviorExecutorService Maven / Gradle / Ivy
package org.umlg.runtime.util;
import org.umlg.runtime.domain.IClassifierEvent;
import java.util.concurrent.*;
public class TinkerClassifierBehaviorExecutorService {
public static TinkerClassifierBehaviorExecutorService INSTANCE = new TinkerClassifierBehaviorExecutorService();
private ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
private CompletionService completionService = new ExecutorCompletionService(executorService);
private TinkerClassifierBehaviorExecutorService() {
super();
}
public void shutdown() {
executorService.shutdown();
}
public Future submit(IClassifierEvent cse) {
return completionService.submit(cse);
}
public Boolean take() {
try {
Future f = this.completionService.take();
return f.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void waitForCompletion(long timeout, TimeUnit unit) {
try {
this.executorService.awaitTermination(timeout, unit);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy