Fix: output device now has queue of size 1. a newer command always overrides the previous one
parent
88991ea9ff
commit
1cf16d8386
|
@ -11,7 +11,7 @@ import meerkat.voting.output.outputcommands.*;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
/**
|
||||
* This is a base class for simple OutputDevices which run asynchronously (as a separate thread).
|
||||
|
@ -21,13 +21,13 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
public abstract class AsyncRunnableOutputDevice implements BallotOutputDevice, Runnable {
|
||||
|
||||
private Logger logger;
|
||||
private LinkedBlockingQueue<OutputCommand> queue;
|
||||
private ArrayBlockingQueue<OutputCommand> queue;
|
||||
private volatile boolean shutDownHasBeenCalled;
|
||||
|
||||
public AsyncRunnableOutputDevice() {
|
||||
logger = LoggerFactory.getLogger(AsyncRunnableOutputDevice.class);
|
||||
logger.info("AsyncRunnableOutputDevice is constructed");
|
||||
queue = new LinkedBlockingQueue<>();
|
||||
queue = new ArrayBlockingQueue<>(1);
|
||||
shutDownHasBeenCalled = false;
|
||||
}
|
||||
|
||||
|
@ -87,24 +87,28 @@ public abstract class AsyncRunnableOutputDevice implements BallotOutputDevice, R
|
|||
SignedEncryptedBallot signedEncryptedBallot,
|
||||
FutureCallback<Void> callback) {
|
||||
logger.debug("Output interface call to commit to ballot");
|
||||
queue.clear();
|
||||
queue.add(new CommitOutputCommand(plaintextBallot, signedEncryptedBallot, (OutputDeviceCommitCallback)callback));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void audit(BallotSecrets ballotSecrets, FutureCallback<Void> callback) {
|
||||
logger.debug("an interface call to audit");
|
||||
queue.clear();
|
||||
queue.add(new AuditOutputCommand(ballotSecrets, (OutputDeviceFinalizeCallback)callback));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void castBallot(FutureCallback<Void> callback) {
|
||||
logger.debug("an interface call to cast ballot");
|
||||
queue.clear();
|
||||
queue.add(new CastOutputCommand((OutputDeviceFinalizeCallback)callback));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelBallot(FutureCallback<Void> callback) {
|
||||
logger.debug("an interface call to cancel the output");
|
||||
queue.clear();
|
||||
queue.add(new CancelOutputCommand((ControllerCallback<Void>)callback));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue