Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.*;
import io.vertx.core.internal.ContextInternal;
import io.vertx.test.core.VertxTestBase;
import io.vertx.test.http.HttpTestBase;
import org.junit.Assert;
Expand All @@ -21,6 +22,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -43,6 +45,22 @@ public void start() {
await();
}

@Test
public void testInstancesUseDistinctEventLoopThreads() {
int instances = 4;
Vertx vertx = vertx(new VertxOptions().setEventLoopPoolSize(2 * instances));
Set<String> eventLoops = Collections.synchronizedSet(new HashSet<>());
vertx.deployVerticle(() -> new AbstractVerticle() {
@Override
public void start() {
CompletableFuture<String> latch = new CompletableFuture<>();
((ContextInternal) context).eventLoop().execute(() -> latch.complete(Thread.currentThread().getName()));
eventLoops.add(latch.join());
}
}, new DeploymentOptions().setInstances(instances).setThreadingModel(ThreadingModel.VIRTUAL_THREAD)).await();
Assert.assertEquals(instances, eventLoops.size());
}

@Test
public void testExecuteBlocking() {
Promise<Void> p = Promise.promise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,9 @@ public Future<?> deploy(DeploymentContext deployment) {
}
break;
case VIRTUAL_THREAD:
if (workerLoop == null) {
context = contextBuilder
.withThreadingModel(ThreadingModel.VIRTUAL_THREAD)
.build();
workerLoop = context.nettyEventLoop();
} else {
context = contextBuilder
.withThreadingModel(ThreadingModel.VIRTUAL_THREAD)
.withEventLoop(workerLoop)
.build();
}
context = contextBuilder
.withThreadingModel(ThreadingModel.VIRTUAL_THREAD)
.build();
break;
default:
context = contextBuilder
Expand Down