Skip to content

Commit 56491ba

Browse files
committed
add hint as possible improvement on loom side
1 parent 8b0bc0d commit 56491ba

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

core/src/main/java/io/netty/loom/GlobalDelegateThreadNettyScheduler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public void onStart(Thread.VirtualThreadTask virtualThreadTask) {
3737
// TODO this is not great for 2 reasons:
3838
// 1. we are doing a remove on a concurrent map even for v threads which are not really interesting to us
3939
// 2. if a vThread will never start, it will leak here forever
40+
// HINT: if we had a VirtualThreadTask::Of(VirtualThread) method, we could perform the assignment BEFORE calling this
41+
// on the vThread factory
42+
// or the vThreadFactory could provide in its build method something to access the VirtualThreadTask of an unstarted VirtualThread
4043
var assignedSchedulerRef = unstartedThreads.remove(virtualThreadTask.thread());
4144
if (assignedSchedulerRef == null) {
4245
// Read-Poller threads are special: if we run from a VThread managed by a VirtualThreadNettyScheduler,

0 commit comments

Comments
 (0)