Skip to content

Commit

Permalink
Fix termination of the fallback virtual thread executor
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier committed Oct 23, 2023
1 parent 996730b commit cdfc1d1
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import io.smallrye.mutiny.infrastructure.Infrastructure;
import io.vertx.core.Vertx;
Expand All @@ -18,6 +19,8 @@
*/
class FallbackVirtualThreadsExecutorService extends AbstractExecutorService {

private AtomicBoolean shutdown = new AtomicBoolean();

@Override
public void execute(Runnable command) {
var context = Vertx.currentContext();
Expand All @@ -33,26 +36,28 @@ public void execute(Runnable command) {

@Override
public void shutdown() {
// no-op
shutdown.compareAndSet(false, true);
}

@Override
public List<Runnable> shutdownNow() {
shutdown.compareAndSet(false, true);
return Collections.EMPTY_LIST;
}

@Override
public boolean isShutdown() {
return false;
return shutdown.get();
}

@Override
public boolean isTerminated() {
return false;
return shutdown.get();
}

@Override
public boolean awaitTermination(long timeout, TimeUnit unit) {
return false;
shutdown.compareAndSet(false, true);
return true;
}
}

0 comments on commit cdfc1d1

Please sign in to comment.