List of usage examples for io.vertx.core.impl ContextInternal executeBlocking
<T> void executeBlocking(Handler<Promise<T>> blockingCodeHandler, TaskQueue queue,
Handler<AsyncResult<T>> resultHandler);
From source file:com.chibchasoft.vertx.util.VertxUtil.java
License:Open Source License
/** * <p>Similar to {@link Context#executeBlocking(Handler, Handler)} but when this method is called several times on * the same provided {@code Context} for the same {@code identifier}, executions associated to that value for that * {@code context} will be executed serially. However, there will be no ordering guarantees in relation to * executions for different identifiers for the same {@code context} or even for the same identifier but for * different {@code context}s.</p> * * <p><b>NOTE:</b> This method relies on a Vertx internal API method * {@link ContextInternal#executeBlocking(Handler, TaskQueue, Handler)}</p> * * @param context The {@link Context} to be used to execute the blocking code * @param identifier Object used to group and serialize executions * @param blockingCodeHandler handler representing the blocking code to run * @param resultHandler handler that will be called when the blocking code is complete * @param <T> the type of the result *//* www .j ava 2 s . co m*/ static <T> void executeBlocking(Context context, Object identifier, Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler) { if (context == null) throw new IllegalStateException("A context is required"); if (identifier == null) throw new IllegalArgumentException("An identifier is required"); ContextInternal contextInternal = (ContextInternal) context; TaskQueue taskQueue = TASK_QUEUES .computeIfAbsent(context, k -> new ConcurrentReferenceHashMap<>(16, ConcurrentReferenceHashMap.ReferenceType.WEAK)) .computeIfAbsent(identifier, k -> new TaskQueue()); contextInternal.executeBlocking(blockingCodeHandler, taskQueue, resultHandler); }