@Override public <T> void executeBlockingInternal(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler) { ContextImpl context = getOrCreateContext(); context.executeBlockingInternal(blockingCodeHandler, resultHandler); }
@Override public <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> asyncResultHandler) { ContextImpl context = getOrCreateContext(); context.executeBlocking(blockingCodeHandler, ordered, asyncResultHandler); }
public void runOnContext(Handler<Void> task) { ContextImpl context = getOrCreateContext(); context.runOnContext(task); }
@Override public synchronized TimeoutStream handler(Handler<Long> handler) { if (handler != null) { if (id != null) { throw new IllegalStateException(); } this.handler = handler; id = scheduleTimeout(getOrCreateContext(), this, delay, periodic); } else { cancel(); } return this; }
public long setPeriodic(long delay, Handler<Long> handler) { return scheduleTimeout(getOrCreateContext(), handler, delay, true); }
public long setTimer(long delay, Handler<Long> handler) { return scheduleTimeout(getOrCreateContext(), handler, delay, false); }
@Override public synchronized WorkerExecutorImpl createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime, TimeUnit maxExecuteTimeUnit) { if (poolSize < 1) { throw new IllegalArgumentException("poolSize must be > 0"); } if (maxExecuteTime < 1) { throw new IllegalArgumentException("maxExecuteTime must be > 0"); } SharedWorkerPool sharedWorkerPool = namedWorkerPools.get(name); if (sharedWorkerPool == null) { ExecutorService workerExec = Executors.newFixedThreadPool(poolSize, new VertxThreadFactory(name + "-", checker, true, maxExecuteTime, maxExecuteTimeUnit)); PoolMetrics workerMetrics = metrics != null ? metrics.createPoolMetrics("worker", name, poolSize) : null; namedWorkerPools.put(name, sharedWorkerPool = new SharedWorkerPool(name, workerExec, workerMetrics)); } else { sharedWorkerPool.refCount++; } ContextImpl context = getOrCreateContext(); WorkerExecutorImpl namedExec = new WorkerExecutorImpl(context, sharedWorkerPool); context.addCloseHook(namedExec); return namedExec; }
@Override public <T> void executeBlockingInternal(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler) { ContextImpl context = getOrCreateContext(); context.executeBlockingInternal(blockingCodeHandler, resultHandler); }
@Override public <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> asyncResultHandler) { ContextImpl context = getOrCreateContext(); context.executeBlocking(blockingCodeHandler, ordered, asyncResultHandler); }
@Override public synchronized TimeoutStream handler(Handler<Long> handler) { if (handler != null) { if (id != null) { throw new IllegalStateException(); } this.handler = handler; id = scheduleTimeout(getOrCreateContext(), this, delay, periodic); } else { cancel(); } return this; }
public void runOnContext(Handler<Void> task) { ContextImpl context = getOrCreateContext(); context.runOnContext(task); }
public long setPeriodic(long delay, Handler<Long> handler) { return scheduleTimeout(getOrCreateContext(), handler, delay, true); }
public long setTimer(long delay, Handler<Long> handler) { return scheduleTimeout(getOrCreateContext(), handler, delay, false); }
@Override public synchronized WorkerExecutorImpl createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime, TimeUnit maxExecuteTimeUnit) { if (poolSize < 1) { throw new IllegalArgumentException("poolSize must be > 0"); } if (maxExecuteTime < 1) { throw new IllegalArgumentException("maxExecuteTime must be > 0"); } SharedWorkerPool sharedWorkerPool = namedWorkerPools.get(name); if (sharedWorkerPool == null) { ExecutorService workerExec = Executors.newFixedThreadPool(poolSize, new VertxThreadFactory(name + "-", checker, true, maxExecuteTime, maxExecuteTimeUnit)); PoolMetrics workerMetrics = metrics != null ? metrics.createPoolMetrics("worker", name, poolSize) : null; namedWorkerPools.put(name, sharedWorkerPool = new SharedWorkerPool(name, workerExec, workerMetrics)); } else { sharedWorkerPool.refCount++; } ContextImpl context = getOrCreateContext(); WorkerExecutorImpl namedExec = new WorkerExecutorImpl(context, sharedWorkerPool); context.addCloseHook(namedExec); return namedExec; }