use of io.vertx.core.impl.TaskQueue in project vert.x by eclipse.
the class ContextTest method testInternalExecuteBlockingWithQueue.
@Test
public void testInternalExecuteBlockingWithQueue() {
ContextInternal context = (ContextInternal) vertx.getOrCreateContext();
TaskQueue[] queues = new TaskQueue[] { new TaskQueue(), new TaskQueue() };
AtomicReference<Thread>[] current = new AtomicReference[queues.length];
waitFor(queues.length);
for (int i = 0; i < queues.length; i++) {
current[i] = new AtomicReference<>();
}
CyclicBarrier barrier = new CyclicBarrier(queues.length);
int numTasks = 10;
for (int i = 0; i < numTasks; i++) {
int ival = i;
for (int j = 0; j < queues.length; j++) {
int jval = j;
context.executeBlocking(fut -> {
if (ival == 0) {
current[jval].set(Thread.currentThread());
} else {
assertSame(Thread.currentThread(), current[jval].get());
}
try {
barrier.await();
} catch (Exception e) {
fail(e);
}
if (ival == numTasks - 1) {
complete();
}
}, queues[j], ar -> {
});
}
}
await();
}
Aggregations