Skip to content

Commit f8d4456

Browse files
committed
Name change
1 parent 9543845 commit f8d4456

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
public class EventLoopScheduler {
1414

15-
public static final class SchedulerRef {
15+
public static final class SharedRef {
1616

1717
private volatile EventLoopScheduler ref;
1818

19-
private SchedulerRef(EventLoopScheduler ref) {
19+
private SharedRef(EventLoopScheduler ref) {
2020
this.ref = ref;
2121
}
2222

@@ -31,13 +31,13 @@ public EventLoopScheduler get() {
3131
* This means that if they try to unpark some virtual thread which belong to this scheduler,
3232
* they can still wakeup the carrier thread. It's more a performance defect, but won't affect correctness.
3333
*/
34-
public record SchedulerContext(long vThreadId, SchedulerRef scheduler) {
34+
public record SchedulingContext(long vThreadId, SharedRef scheduler) {
3535

3636
/**
3737
* Get the assigned scheduler for the current thread, or null if this thread is not assigned to any scheduler.
3838
*/
3939
@Override
40-
public SchedulerRef scheduler() {
40+
public SharedRef scheduler() {
4141
// TODO consider returning EMPTY_SCHEDULER_REF instead of null
4242
return (Thread.currentThread().threadId() == vThreadId) ? scheduler : null;
4343
}
@@ -50,8 +50,8 @@ public SchedulerRef scheduler() {
5050
private static final long RUNNING_YIELD_US = TimeUnit.MICROSECONDS.toNanos(Integer.getInteger("io.netty.loom.running.yield.us", 1));
5151
private static final long IDLE_YIELD_US = TimeUnit.MICROSECONDS.toNanos(Integer.getInteger("io.netty.loom.idle.yield.us", 1));
5252
// This is required to allow sub-pollers to run on the correct scheduler
53-
private static final ScopedValue<SchedulerContext> CURRENT_SCHEDULER = ScopedValue.newInstance();
54-
private static final SchedulerContext EMPTY_SCHEDULER_CONTEXT = new SchedulerContext(-1, null);
53+
private static final ScopedValue<SchedulingContext> CURRENT_SCHEDULER = ScopedValue.newInstance();
54+
private static final SchedulingContext EMPTY_SCHEDULER_CONTEXT = new SchedulingContext(-1, null);
5555
private final MpscUnboundedStream<Runnable> runQueue;
5656
private final ManualIoEventLoop ioEventLoop;
5757
private final Thread eventLoopThread;
@@ -60,10 +60,10 @@ public SchedulerRef scheduler() {
6060
private volatile Runnable eventLoopContinuatioToRun;
6161
private final ThreadFactory vThreadFactory;
6262
private final AtomicBoolean eventLoopIsRunning;
63-
private final SchedulerRef sharedRef;
63+
private final SharedRef sharedRef;
6464

6565
public EventLoopScheduler(IoEventLoopGroup parent, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int resumedContinuationsExpectedCount) {
66-
sharedRef = new SchedulerRef(this);
66+
sharedRef = new SharedRef(this);
6767
eventLoopIsRunning = new AtomicBoolean(false);
6868
runQueue = new MpscUnboundedStream<>(resumedContinuationsExpectedCount);
6969
carrierThread = threadFactory.newThread(this::virtualThreadSchedulerLoop);
@@ -72,7 +72,7 @@ public EventLoopScheduler(IoEventLoopGroup parent, ThreadFactory threadFactory,
7272
NettyScheduler.assignUnstarted(rawVTFactory.newThread(
7373
() -> // this can be inherited by any thread created in the context of this virtual thread
7474
// but only the original virtual thread will have the correct scheduler context
75-
ScopedValue.where(CURRENT_SCHEDULER, new SchedulerContext(Thread.currentThread().threadId(), sharedRef)).run(runnable)
75+
ScopedValue.where(CURRENT_SCHEDULER, new SchedulingContext(Thread.currentThread().threadId(), sharedRef)).run(runnable)
7676
), sharedRef);
7777
eventLoopThread = vThreadFactory.newThread(() -> FastThreadLocalThread.runWithFastThreadLocal(this::nettyEventLoop));
7878
ioEventLoop = new ManualIoEventLoop(parent, eventLoopThread,
@@ -240,7 +240,7 @@ public boolean execute(Thread.VirtualThreadTask task) {
240240
return true;
241241
}
242242

243-
public static SchedulerContext currentThreadSchedulerContext() {
243+
public static SchedulingContext currentThreadSchedulerContext() {
244244
return CURRENT_SCHEDULER.orElse(EMPTY_SCHEDULER_CONTEXT);
245245
}
246246
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.netty.loom;
22

3-
import io.netty.loom.EventLoopScheduler.SchedulerRef;
3+
import io.netty.loom.EventLoopScheduler.SharedRef;
44

55
import java.lang.invoke.VarHandle;
66
import java.util.concurrent.ConcurrentHashMap;
@@ -25,7 +25,7 @@ public class NettyScheduler implements Thread.VirtualThreadScheduler {
2525

2626
private final Thread.VirtualThreadScheduler jdkBuildinScheduler;
2727

28-
private final ConcurrentHashMap<Thread, SchedulerRef> unstartedThreads = new ConcurrentHashMap<>();
28+
private final ConcurrentHashMap<Thread, SharedRef> unstartedThreads = new ConcurrentHashMap<>();
2929

3030
public NettyScheduler(Thread.VirtualThreadScheduler jdkBuildinScheduler) {
3131
this.jdkBuildinScheduler = jdkBuildinScheduler;
@@ -85,7 +85,7 @@ public void onStart(Thread.VirtualThreadTask virtualThreadTask) {
8585
@Override
8686
public void onContinue(Thread.VirtualThreadTask virtualThreadTask) {
8787
var attachment = virtualThreadTask.attachment();
88-
if (attachment instanceof SchedulerRef ref) {
88+
if (attachment instanceof SharedRef ref) {
8989
var assignedScheduler = ref.get();
9090
if (assignedScheduler != null) {
9191
if (assignedScheduler.execute(virtualThreadTask)) {
@@ -98,7 +98,7 @@ public void onContinue(Thread.VirtualThreadTask virtualThreadTask) {
9898
jdkBuildinScheduler.onContinue(virtualThreadTask);
9999
}
100100

101-
static Thread assignUnstarted(Thread unstarted, SchedulerRef ref) {
101+
static Thread assignUnstarted(Thread unstarted, SharedRef ref) {
102102
INSTANCE.unstartedThreads.put(unstarted, ref);
103103
return unstarted;
104104
}

core/src/test/java/io/netty/loom/VirtualMultithreadIoEventLoopGroupTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void schedulerIsInheritedByForkedVTFromTheRightFactory() throws InterruptedExcep
353353
void schedulerIsNotInheritedByForkedVT() throws InterruptedException, ExecutionException {
354354
try (var group = new VirtualMultithreadIoEventLoopGroup(1, LocalIoHandler.newFactory())) {
355355
final var vThreadFactory = group.submit(group::vThreadFactory).get();
356-
var schedulerRef = new CompletableFuture<EventLoopScheduler.SchedulerRef>();
356+
var schedulerRef = new CompletableFuture<EventLoopScheduler.SharedRef>();
357357
vThreadFactory.newThread(() -> {
358358
try (var scope = StructuredTaskScope.open(allSuccessfulOrThrow())) {
359359
var task = scope.fork(() -> EventLoopScheduler.currentThreadSchedulerContext().scheduler());

0 commit comments

Comments
 (0)