Skip to content

feat: save the storage file on a background thread by default - #89

Merged
imurashka merged 9 commits into
mainfrom
ivan/background-writer
Aug 10, 2026
Merged

imurashka merged 9 commits into
mainfrom
ivan/background-writer

Conversation

@imurashka

Copy link
Copy Markdown
Contributor

Saving no longer blocks the caller until the data is on disk. Changes are still serialized on the calling thread, and only the file write is handed over to a shared background thread, one storage at a time. A newer change replaces an unwritten older one, since the file is always written whole and only the last state matters.

Save() keeps its meaning and blocks until the data has actually reached the disk, and disposing a storage flushes whatever is still pending. Pass SaveOnBackgroundThread(false) to the builder to get the previous behaviour, where every change writes the file before returning.

The trade-off is that a change now reaches the disk a moment after the call returns instead of during it. Publication stays atomic, so a process killed inside that window keeps the previous generation intact and loses only the last change.

@imurashka
imurashka merged commit 22c8eef into main Aug 10, 2026
1 check passed
@imurashka
imurashka deleted the ivan/background-writer branch August 10, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant