Skip to content

Commit

Permalink
Add missing worker context creation method for virtual threads
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Oct 18, 2023
1 parent aaa87aa commit 6dcac21
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
15 changes: 12 additions & 3 deletions src/main/java/io/vertx/core/impl/VertxImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,20 @@ public ContextImpl createEventLoopContext() {
return createEventLoopContext(null, closeFuture, null, Thread.currentThread().getContextClassLoader());
}

@Override
public ContextImpl createWorkerContext(Deployment deployment, CloseFuture closeFuture, WorkerPool workerPool, ClassLoader tccl) {
private ContextImpl createWorkerContext(EventLoop eventLoop, CloseFuture closeFuture, WorkerPool workerPool, Deployment deployment, ClassLoader tccl) {
TaskQueue orderedTasks = new TaskQueue();
WorkerPool wp = workerPool != null ? workerPool : this.workerPool;
return new ContextImpl(this, false, eventLoopGroup.next(), new WorkerExecutor(wp, orderedTasks), internalWorkerPool, wp, orderedTasks, deployment, closeFuture, disableTCCL ? null : tccl);
return new ContextImpl(this, false, eventLoop, new WorkerExecutor(wp, orderedTasks), internalWorkerPool, wp, orderedTasks, deployment, closeFuture, disableTCCL ? null : tccl);
}

@Override
public ContextInternal createWorkerContext(EventLoop eventLoop, WorkerPool workerPool, ClassLoader tccl) {
return createWorkerContext(eventLoop, closeFuture, workerPool, null, tccl);
}

@Override
public ContextImpl createWorkerContext(Deployment deployment, CloseFuture closeFuture, WorkerPool workerPool, ClassLoader tccl) {
return createWorkerContext(eventLoopGroup.next(), closeFuture, workerPool, deployment, tccl);
}

@Override
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/io/vertx/core/impl/VertxInternal.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,29 @@ default <C> C createSharedClient(String clientKey, String clientName, CloseFutur
*/
ContextInternal createEventLoopContext(Deployment deployment, CloseFuture closeFuture, WorkerPool workerPool, ClassLoader tccl);

/**
* @return event loop context
*/
ContextInternal createEventLoopContext(EventLoop eventLoop, WorkerPool workerPool, ClassLoader tccl);

/**
* @return event loop context
*/
ContextInternal createEventLoopContext();

/**
* @return worker loop context
* @return worker context
*/
ContextInternal createWorkerContext(Deployment deployment, CloseFuture closeFuture, WorkerPool pool, ClassLoader tccl);
ContextInternal createWorkerContext(Deployment deployment, CloseFuture closeFuture, WorkerPool workerPool, ClassLoader tccl);

/**
* @return worker context
*/
ContextInternal createWorkerContext(EventLoop eventLoop, WorkerPool workerPool, ClassLoader tccl);

/**
* @return worker context
*/
ContextInternal createWorkerContext();

@Override
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/io/vertx/core/impl/VertxWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,13 @@ public ContextInternal createEventLoopContext() {
}

@Override
public ContextInternal createWorkerContext(Deployment deployment, CloseFuture closeFuture, WorkerPool pool, ClassLoader tccl) {
return delegate.createWorkerContext(deployment, closeFuture, pool, tccl);
public ContextInternal createWorkerContext(EventLoop eventLoop, WorkerPool workerPool, ClassLoader tccl) {
return delegate.createWorkerContext(eventLoop, workerPool, tccl);
}

@Override
public ContextInternal createWorkerContext(Deployment deployment, CloseFuture closeFuture, WorkerPool workerPool, ClassLoader tccl) {
return delegate.createWorkerContext(deployment, closeFuture, workerPool, tccl);
}

@Override
Expand Down

0 comments on commit 6dcac21

Please sign in to comment.