private long scheduleTimeout(ContextImpl context, Handler<Long> handler, long delay, boolean periodic) { if (delay < 1) { throw new IllegalArgumentException("Cannot schedule a timer with delay < 1 ms"); } long timerId = timeoutCounter.getAndIncrement(); InternalTimerHandler task = new InternalTimerHandler(timerId, handler, periodic, delay, context); timeouts.put(timerId, task); context.addCloseHook(task); return timerId; }
@Override public final <T> void executeFromIO(T value, Handler<T> task) { if (THREAD_CHECKS) { checkEventLoopThread(); } execute(value, task); }
@Override public void put(String key, Object value) { contextData().put(key, value); }
vertx.createEventLoopContext(deploymentID, pool, conf, tccl); if (workerExec != null) { context.addCloseHook(workerExec); context.setDeployment(deployment); deployment.addVerticle(new VerticleHolder(verticle, context)); context.runOnContext(v -> { try { verticle.init(vertx, context);
@Override public <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler) { executeBlocking(blockingCodeHandler, true, resultHandler); }
@Override public <T> void executeBlockingInternal(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler) { ContextImpl context = getOrCreateContext(); context.executeBlockingInternal(blockingCodeHandler, resultHandler); }
@Override public void runOnContext(Handler<Void> task) { try { executeAsync(task); } catch (RejectedExecutionException ignore) { // Pool is already shut down } }
protected ContextImpl(VertxInternal vertx, WorkerPool internalBlockingPool, WorkerPool workerPool, String deploymentID, JsonObject config, ClassLoader tccl) { this(vertx, getEventLoop(vertx), internalBlockingPool, workerPool, deploymentID, config, tccl); }
@Override public final void executeFromIO(Handler<Void> task) { executeFromIO(null, task); }
@Override public boolean isWorkerContext() { return !isEventLoopContext(); }
vertx.createEventLoopContext(deploymentID, pool, conf, tccl); if (workerExec != null) { context.addCloseHook(workerExec); context.setDeployment(deployment); deployment.addVerticle(new VerticleHolder(verticle, context)); context.runOnContext(v -> { try { verticle.init(vertx, context);
@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 <T> void executeBlockingInternal(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler) { ContextImpl context = getOrCreateContext(); context.executeBlockingInternal(blockingCodeHandler, resultHandler); }
@Override public void runOnContext(Handler<Void> task) { try { executeAsync(task); } catch (RejectedExecutionException ignore) { // Pool is already shut down } }
protected ContextImpl(VertxInternal vertx, WorkerPool internalBlockingPool, WorkerPool workerPool, String deploymentID, JsonObject config, ClassLoader tccl) { this(vertx, getEventLoop(vertx), internalBlockingPool, workerPool, deploymentID, config, tccl); }
@Override public final void executeFromIO(Handler<Void> task) { executeFromIO(null, task); }
@Override public boolean isWorkerContext() { return !isEventLoopContext(); }
@Override public <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> resultHandler) { executeBlocking(blockingCodeHandler, resultHandler, workerPool.executor(), ordered ? orderedTasks : null, workerPool.metrics()); }
@Override public final <T> void executeFromIO(T value, Handler<T> task) { if (THREAD_CHECKS) { checkEventLoopThread(); } execute(value, task); }
@Override public boolean remove(String key) { return contextData().remove(key) != null; }