Add Handle::into_inner method

This commit is contained in:
Micha Reiser 2024-07-26 10:23:56 +02:00
parent e4ce917f6e
commit c66f600c06
No known key found for this signature in database

View file

@ -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.