GracefulShutdownFirehose: MutableBoolean -> AtomicBoolean

This commit is contained in:
Gian Merlino 2013-03-19 18:16:13 -07:00
parent 424e899760
commit ce1ef94061
1 changed files with 4 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import java.io.IOException;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
/** /**
*/ */
@ -31,7 +32,7 @@ public class GracefulShutdownFirehose implements Firehose
private final ScheduledExecutorService scheduledExecutor; private final ScheduledExecutorService scheduledExecutor;
private final RejectionPolicy rejectionPolicy; private final RejectionPolicy rejectionPolicy;
private final MutableBoolean hasMore = new MutableBoolean(true); private final AtomicBoolean hasMore = new AtomicBoolean(true);
private volatile boolean shutdown = false; private volatile boolean shutdown = false;
public GracefulShutdownFirehose( public GracefulShutdownFirehose(
@ -74,7 +75,7 @@ public class GracefulShutdownFirehose implements Firehose
public ScheduledExecutors.Signal call() throws Exception public ScheduledExecutors.Signal call() throws Exception
{ {
try { try {
hasMore.setValue(false); hasMore.set(false);
} }
catch (Exception e) { catch (Exception e) {
throw Throwables.propagate(e); throw Throwables.propagate(e);
@ -91,7 +92,7 @@ public class GracefulShutdownFirehose implements Firehose
@Override @Override
public boolean hasMore() public boolean hasMore()
{ {
return hasMore.booleanValue() && firehose.hasMore(); return hasMore.get() && firehose.hasMore();
} }
@Override @Override