// Write out buffered data if any, then call Success on completion void Flush(Cache.IAppendCompletion completion) { if (bufferedData == null) // no buffered data being held { completion.Success(); } else { // the completion will be called once the data has been // written to disk bufferedCompletions.Add(completion); QueueWrite(); } }