Support for flush on refresh

Due to temporal ordering issues with flushing. The document will not be
flushed officially to disk unless the very last resource to touch it has
a change.

This commit adds a 'flush_document!' method and allows it to be called
on a self refresh that should occur after all resources interacting with
the document have been processed.