You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Read-Poller threads are special: if we run from a VThread managed by a VirtualThreadNettyScheduler,
43
+
// we want should continue using that same scheduler for the Read-Poller thread.
44
+
varcurrentThread = Thread.currentThread();
45
+
if (currentThread.isVirtual()) {
46
+
// TODO https://github.com/openjdk/loom/blob/12ddf39bb59252a8274d8b937bd075b2a6dbc3f8/src/java.base/share/classes/java/lang/VirtualThread.java#L270C18-L270C33
47
+
// in theory should be easy to provide a VirtualThreadTask::current method to avoid the ScopedValue lookup
// TODO per carrier sub-pollers goes here, but we want them to inherit the scheduler from the caller context
50
+
if (schedulerRef != null) {
51
+
varscheduler = schedulerRef.get();
52
+
// See https://github.com/openjdk/loom/blob/12ddf39bb59252a8274d8b937bd075b2a6dbc3f8/src/java.base/share/classes/sun/nio/ch/Poller.java#L723C48-L723C59
53
+
if (scheduler != null) {
54
+
if (virtualThreadTask.thread().getName().endsWith("-Read-Poller")) {
55
+
// attach the assigned scheduler to the task
56
+
virtualThreadTask.attach(schedulerRef);
57
+
if (scheduler.execute(virtualThreadTask)) {
58
+
return;
59
+
}
60
+
virtualThreadTask.attach(null);
61
+
}
62
+
}
63
+
}
64
+
}
65
+
} else {
66
+
varscheduler = assignedSchedulerRef.get();
67
+
if (scheduler != null) {
68
+
// attach the assigned scheduler to the task
69
+
virtualThreadTask.attach(assignedSchedulerRef);
70
+
if (scheduler.execute(virtualThreadTask)) {
71
+
return;
72
+
}
50
73
}
51
-
// the v thread has been rejected by its assigned scheduler, clean it up and fallback to JDK
74
+
// the v thread has been rejected by its assigned scheduler or its scheduler is gone
0 commit comments