Skip to content

Commit

Permalink
Add Handle::into_inner method
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Jul 26, 2024
1 parent e4ce917 commit c66f600
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit c66f600

Please sign in to comment.