下面列出了java.util.concurrent.Executor#getClass ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void addExecutorWatchdog(String name, Executor exec) {
if (exec instanceof ThreadPoolExecutor) {
WatchdogService.addWatchdogCheck(new ThreadPoolExecutorWatchdog(name,(ThreadPoolExecutor)exec));
} else {
throw new RuntimeException("cannot monitor executor of type: " + exec.getClass());
}
}
public static Executor serialized(Executor parent, int bufferSize) {
return parent instanceof SerializingExecutor
|| parent instanceof io.grpc.internal.SerializingExecutor
|| parent instanceof OrderedEventExecutor
|| parent.getClass() == GSE_CLASS
? parent : new SerializingExecutor(parent, bufferSize);
}
private CompletableSearchServer(SearchServer backend, Executor executor, boolean shutdownExecutorOnClose) {
if(shutdownExecutorOnClose && !(executor instanceof ExecutorService)) {
throw new IllegalArgumentException("shutdownExecutorOnClose requires 'executor' being an 'ExecutorService', actually got: " + executor.getClass());
}
this.backend = backend;
this.executor = executor;
this.shutdownExecutorOnClose = shutdownExecutorOnClose;
}
/**
* Creates a threaded request handler
*
* @param executor the executor to use to execute requests
* @param metric the metric object to which event in this are to be collected
* @param allowAsyncResponse true to allow the response header to be created asynchronously.
* If false (default), this will create an error response if the response header
* is not returned by the subclass of this before handleRequest returns.
*/
@Inject
protected ThreadedRequestHandler(Executor executor, Metric metric, boolean allowAsyncResponse) {
executor.getClass(); // throws NullPointerException
this.executor = executor;
this.metric = (metric == null) ? new NullRequestMetric() : metric;
this.allowAsyncResponse = allowAsyncResponse;
}