Bug 722575 - make SerialRecordConsumer.consumerIsDone() thread-safe. r=rnewman

This commit is contained in:
Nick Alexander 2012-03-02 17:36:15 -08:00
parent 7ca96b8ebd
commit b81d67db7c

View File

@ -49,7 +49,7 @@ import android.util.Log;
class SerialRecordConsumer extends RecordConsumer { class SerialRecordConsumer extends RecordConsumer {
private static final String LOG_TAG = "SerialRecordConsumer"; private static final String LOG_TAG = "SerialRecordConsumer";
protected boolean stopEventually = false; protected boolean stopEventually = false;
private long counter = 0; private volatile long counter = 0;
public SerialRecordConsumer(RecordsConsumerDelegate delegate) { public SerialRecordConsumer(RecordsConsumerDelegate delegate) {
this.delegate = delegate; this.delegate = delegate;
@ -130,7 +130,8 @@ class SerialRecordConsumer extends RecordConsumer {
} }
private void consumerIsDone() { private void consumerIsDone() {
info("Consumer is done. Processed " + counter + ((counter == 1) ? " record." : " records.")); long counterNow = this.counter;
info("Consumer is done. Processed " + counterNow + ((counterNow == 1) ? " record." : " records."));
delegate.consumerIsDone(stopImmediately); delegate.consumerIsDone(stopImmediately);
} }