Skip to content

Commit

Permalink
address comment by @ikhoon
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhee17 committed Jan 23, 2024
1 parent 6b3849e commit 8750768
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.linecorp.armeria.internal.common;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.concurrent.TimeUnit.NANOSECONDS;

import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -64,10 +65,6 @@ final class DefaultCancellationScheduler implements CancellationScheduler {
private static final AtomicLongFieldUpdater<DefaultCancellationScheduler> pendingTimeoutNanosUpdater =
AtomicLongFieldUpdater.newUpdater(DefaultCancellationScheduler.class, "pendingTimeoutNanos");

private static final AtomicReferenceFieldUpdater<DefaultCancellationScheduler, EventExecutor>
eventLoopUpdater = AtomicReferenceFieldUpdater.newUpdater(
DefaultCancellationScheduler.class, EventExecutor.class, "eventLoop");

private static final Runnable noopPendingTask = () -> {
};

Expand All @@ -78,7 +75,7 @@ final class DefaultCancellationScheduler implements CancellationScheduler {
private long timeoutNanos;
private long startTimeNanos;
@Nullable
private volatile EventExecutor eventLoop;
private EventExecutor eventLoop;
@Nullable
private CancellationTask task;
@Nullable
Expand Down Expand Up @@ -125,9 +122,8 @@ public void initAndStart(EventExecutor eventLoop, CancellationTask task) {

@Override
public void init(EventExecutor eventLoop) {
if (!eventLoopUpdater.compareAndSet(this, null, eventLoop)) {
throw new IllegalStateException("Can't init() more than once");
}
checkState(this.eventLoop == null, "Scheduler is already initialized with %s", this.eventLoop);
this.eventLoop = eventLoop;
}

@Override
Expand Down

0 comments on commit 8750768

Please sign in to comment.