private ExecutorService immediateExecutorService() { return new AbstractExecutorService() { @Override public void shutdown() { } @Override public List<Runnable> shutdownNow() { return null; } @Override public boolean isShutdown() { return false; } @Override public boolean isTerminated() { return false; } @Override public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException { return false; } @Override public void execute(Runnable runnable) { runnable.run(); } }; }
public EmptyFunctionBlacklist() { super("EMPTY", new AbstractExecutorService() { @Override public void shutdown() { } @Override public List<Runnable> shutdownNow() { return null; } @Override public boolean isShutdown() { return true; } @Override public boolean isTerminated() { return true; } @Override public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException { return true; } @Override public void execute(final Runnable command) { } }); }
@Override protected ExecutorService getDefaultExecutorService() { if (isMultiThreaded()) { return super.getDefaultExecutorService(); } return new AbstractExecutorService() { boolean terminated; public void shutdown() { terminated = true; } public List<Runnable> shutdownNow() { shutdown(); return null; } public boolean isShutdown() { return terminated; } public boolean isTerminated() { return terminated; } public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException { shutdown(); return terminated; } public void execute(Runnable runnable) { runnable.run(); } }; }
public FriendlyCompletionService(Executor executor) { if (executor == null) throw new NullPointerException(); this.executor = executor; if (executor instanceof AbstractExecutorService) { this.aes = (AbstractExecutorService) executor; } else { this.aes = null; } this.completionQueue = new LinkedBlockingQueue<Future<V>>(); }
public FriendlyCompletionService(Executor executor, BlockingQueue<Future<V>> completionQueue) { if (executor == null || completionQueue == null) throw new NullPointerException(); this.executor = executor; if (executor instanceof AbstractExecutorService) { this.aes = (AbstractExecutorService) executor; } else { this.aes = null; } this.completionQueue = completionQueue; }
/** * Create an {@link ExecutorService} which runs jobs in main thread. */ public static ExecutorService newSynchronousExecutorService() { return new AbstractExecutorService() { @Override public void execute(Runnable command) { command.run(); } @Override public void shutdown() { throw new UnsupportedOperationException(); } @Override public List<Runnable> shutdownNow() { throw new UnsupportedOperationException(); } @Override public boolean isShutdown() { throw new UnsupportedOperationException(); } @Override public boolean isTerminated() { throw new UnsupportedOperationException(); } @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { throw new UnsupportedOperationException(); } }; }
public void pendClientTask(ClientTask task, AbstractExecutorService executor) { if (sessionCreatedOnServer.get()) { executor.execute(task); } else { synchronized (sessionCreatedOnServer) { if (sessionCreatedOnServer.get()) { executor.execute(task); } else { pendingTasks.add(task); } } } }
public void onSessionCreatedOnServer(AbstractExecutorService executor) { synchronized (sessionCreatedOnServer) { if (!sessionCreatedOnServer.get()) { for (ClientTask task : pendingTasks) { executor.execute(task); } pendingTasks = null; } sessionCreatedOnServer.compareAndSet(false, true); } }
public ExecutorServiceThreadPool(final AbstractExecutorService pool) { this.pool = pool; }
@Override public AbstractExecutorService executor() { return pool; }
private static ExecutorService wrapExecutor(final Executor executor) { return new AbstractExecutorService() { private volatile boolean isShutdown = false; private volatile boolean isTerminated = false; @Override public void shutdown() { isShutdown = true; } @Override public List<Runnable> shutdownNow() { return Lists.newArrayList(); } @Override public boolean isShutdown() { return isShutdown; } @Override public boolean isTerminated() { return isTerminated; } @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { throw new UnsupportedOperationException(); } @Override public void execute(Runnable command) { try { executor.execute(command); } finally { isShutdown = true; isTerminated = true; } } }; }
@BeforeClass public static void beforeSuite() { executorContext = Mockito.mock(ExecutorContext.class); executor = Executors.newSingleThreadScheduledExecutor(); Mockito.when(executorContext.getApiExecutor()).thenReturn(new AbstractExecutorService() { @Override public void execute(Runnable command) { command.run(); } @Override public List<Runnable> shutdownNow() { // TODO Auto-generated method stub return null; } @Override public void shutdown() { // TODO Auto-generated method stub } @Override public boolean isTerminated() { // TODO Auto-generated method stub return false; } @Override public boolean isShutdown() { // TODO Auto-generated method stub return false; } @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { // TODO Auto-generated method stub return false; } }); Mockito.when(executorContext.getCallbackExecutor()).thenReturn(executor); Mockito.when(executorContext.getScheduledExecutor()).thenReturn(executor); }
protected TestSession( final UUID theIdentifier, final AbstractExecutorService theDelegationExecutorService, final int bufferSize) { super(theIdentifier, theDelegationExecutorService, bufferSize); }
AbstractExecutorService executor();