1111import io .netty .channel .ManualIoEventLoop ;
1212import io .netty .util .concurrent .FastThreadLocalThread ;
1313
14- public class VirtualThreadNettyScheduler {
14+ public class EventLoopScheduler {
1515
1616 private static final long MAX_WAIT_TASKS_NS = TimeUnit .HOURS .toNanos (1 );
1717 // These are the soft-guaranteed yield times for the event loop whilst Thread.yield() is called.
@@ -20,8 +20,8 @@ public class VirtualThreadNettyScheduler {
2020 private static final long RUNNING_YIELD_US = TimeUnit .MICROSECONDS .toNanos (Integer .getInteger ("io.netty.loom.running.yield.us" , 1 ));
2121 private static final long IDLE_YIELD_US = TimeUnit .MICROSECONDS .toNanos (Integer .getInteger ("io.netty.loom.idle.yield.us" , 1 ));
2222 // This is required to allow sub-pollers to run on the correct scheduler
23- private static final ScopedValue <AtomicReference <VirtualThreadNettyScheduler >> CURRENT_SCHEDULER = ScopedValue .newInstance ();
24- private static final AtomicReference <VirtualThreadNettyScheduler > EMPTY_REFERENCE = new AtomicReference <>();
23+ private static final ScopedValue <AtomicReference <EventLoopScheduler >> CURRENT_SCHEDULER = ScopedValue .newInstance ();
24+ private static final AtomicReference <EventLoopScheduler > EMPTY_REFERENCE = new AtomicReference <>();
2525 private final MpscUnboundedStream <Runnable > runQueue ;
2626 private final ManualIoEventLoop ioEventLoop ;
2727 private final Thread eventLoopThread ;
@@ -30,16 +30,16 @@ public class VirtualThreadNettyScheduler {
3030 private volatile Runnable eventLoopContinuatioToRun ;
3131 private final ThreadFactory vThreadFactory ;
3232 private final AtomicBoolean running ;
33- private final AtomicReference <VirtualThreadNettyScheduler > schedulerReference ;
33+ private final AtomicReference <EventLoopScheduler > schedulerReference ;
3434
35- public VirtualThreadNettyScheduler (IoEventLoopGroup parent , ThreadFactory threadFactory , IoHandlerFactory ioHandlerFactory , int resumedContinuationsExpectedCount ) {
35+ public EventLoopScheduler (IoEventLoopGroup parent , ThreadFactory threadFactory , IoHandlerFactory ioHandlerFactory , int resumedContinuationsExpectedCount ) {
3636 schedulerReference = new AtomicReference <>(this );
3737 running = new AtomicBoolean (false );
3838 runQueue = new MpscUnboundedStream <>(resumedContinuationsExpectedCount );
3939 carrierThread = threadFactory .newThread (this ::virtualThreadSchedulerLoop );
4040 var rawVTFactory = Thread .ofVirtual ().factory ();
4141 vThreadFactory = runnable ->
42- GlobalDelegateThreadNettyScheduler .assignUnstarted (rawVTFactory .newThread (
42+ NettyScheduler .assignUnstarted (rawVTFactory .newThread (
4343 () -> ScopedValue .where (CURRENT_SCHEDULER , schedulerReference ).run (runnable )), schedulerReference );
4444 eventLoopThread = vThreadFactory .newThread (() -> FastThreadLocalThread .runWithFastThreadLocal (this ::nettyEventLoop ));
4545 ioEventLoop = new ManualIoEventLoop (parent , eventLoopThread ,
@@ -199,7 +199,7 @@ public boolean execute(Thread.VirtualThreadTask task) {
199199 return true ;
200200 }
201201
202- public static AtomicReference <VirtualThreadNettyScheduler > currentRef () {
202+ public static AtomicReference <EventLoopScheduler > currentRef () {
203203 var ref = CURRENT_SCHEDULER .orElse (EMPTY_REFERENCE );
204204 return ref == EMPTY_REFERENCE ? null : ref ;
205205 }
0 commit comments