This repository has been archived by the owner on Dec 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make opening & closing idempotent and add events
Very similar to `levelup` but more precise. If `open()` and `close()` are called repeatedly (while the previous call has not yet completed) the last call dictates the final status. Callbacks are not called until any pending state changes are done, meaning that the status is not 'opening' or 'closing'. Same for events. For example, in a sequence of calls like `open(); close(); open()` the final status will be 'open', only the second call will error, only an 'open' event is emitted, and all callbacks will see that status is 'open'. The callbacks are called in the order that the `open()` or `close()` calls were made. In addition, unlike on `levelup`, it is safe to call `open()` while status is 'closing'. It will wait for closing to complete and then reopen. We should now have complete safety, including in `leveldown` because the native code there delays `close()` if any operations are in flight. In other words, the JavaScript side in `abstract-leveldown` prevents new operations before opening the db, and the C++ side in `leveldown` prevents closing the db before operations completed. Ref Level/leveldown#8 Ref Level/community#58
- Loading branch information
Showing
3 changed files
with
209 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters