Merge "Fix issue with saving protos to disk during shutdown." into rvc-qpr-dev
This commit is contained in:
@@ -185,22 +185,23 @@ abstract class AbstractProtoDiskReadWriter<T> {
|
|||||||
* is useful for when device is powering off.
|
* is useful for when device is powering off.
|
||||||
*/
|
*/
|
||||||
@MainThread
|
@MainThread
|
||||||
synchronized void saveImmediately(@NonNull String fileName, @NonNull T data) {
|
void saveImmediately(@NonNull String fileName, @NonNull T data) {
|
||||||
mScheduledFileDataMap.put(fileName, data);
|
synchronized (this) {
|
||||||
|
mScheduledFileDataMap.put(fileName, data);
|
||||||
|
}
|
||||||
triggerScheduledFlushEarly();
|
triggerScheduledFlushEarly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
private synchronized void triggerScheduledFlushEarly() {
|
private void triggerScheduledFlushEarly() {
|
||||||
if (mScheduledFileDataMap.isEmpty() || mScheduledExecutorService.isShutdown()) {
|
synchronized (this) {
|
||||||
return;
|
if (mScheduledFileDataMap.isEmpty() || mScheduledExecutorService.isShutdown()) {
|
||||||
}
|
return;
|
||||||
// Cancel existing future.
|
}
|
||||||
if (mScheduledFuture != null) {
|
// Cancel existing future.
|
||||||
|
if (mScheduledFuture != null) {
|
||||||
// We shouldn't need to interrupt as this method and threaded task
|
mScheduledFuture.cancel(true);
|
||||||
// #flushScheduledData are both synchronized.
|
}
|
||||||
mScheduledFuture.cancel(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit flush and blocks until it completes. Blocking will prevent the device from
|
// Submit flush and blocks until it completes. Blocking will prevent the device from
|
||||||
|
|||||||
Reference in New Issue
Block a user