Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Handle::into_inner method #531

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ impl<Db: HasStorage> Handle<Db> {
Arc::get_mut(self.db_mut()).expect("other threads remain active despite cancellation")
}

/// Returns the inner database, consuming the handle.
///
/// If other handles are active, this method sets the cancellation flag
/// and blocks until they are dropped.
pub fn into_inner(mut self) -> Db {
self.cancel_others();
Arc::into_inner(self.db.take().unwrap())
.expect("other threads remain active despite cancellation")
}

// ANCHOR: cancel_other_workers
/// Sets cancellation flag and blocks until all other workers with access
/// to this storage have completed.
Expand Down
Loading