code: private void enqueueDiskWrite(final MemoryCommitResult mcr,
                                    final Runnable postWriteRunnable) {
          final Runnable writeToDiskRunnable = new Runnable() {
              public void run() {
                  synchronized (mWritingToDiskLock) {
                      writeToFile(mcr);
                  }
                  synchronized (XmlStorage.this) {
                      mDiskWritesInFlight--;
                  }
                  if (postWriteRunnable != null) {
                      postWriteRunnable.run();
                  }
              }
          };
  
          final boolean isFromSyncCommit = (postWriteRunnable == null);
  
          // Typical #commit() path with fewer allocations, doing a write on
          // the current thread.
          if (isFromSyncCommit) {
              boolean wasEmpty = false;
              synchronized (XmlStorage.this) {
                  wasEmpty = mDiskWritesInFlight == 1;
              }
              if (wasEmpty) {
                  writeToDiskRunnable.run();
                  return;
              }
          }
  
          QueuedWork.singleThreadExecutor().execute(writeToDiskRunnable);
      }
docs: Enqueue an already-committed-to-memory result to be written
  to disk.
  
  They will be written to disk one-at-a-time in the order
  that they're enqueued.
  
  @param postWriteRunnable if non-null, we're being called
  from apply() and this is the runnable to run after
  the write proceeds.  if null (from a regular commit()),
  then we're allowed to do this disk write on the main
  thread (which in addition to reducing allocations and
  creating a background thread, this has the advantage that
  we catch them in userdebug StrictMode reports to convert
  them where possible to apply() ...)