From c66f600c0666944d4f93e3acb82c458f6dea6d74 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 26 Jul 2024 10:23:56 +0200 Subject: [PATCH] Add Handle::into_inner method --- src/handle.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/handle.rs b/src/handle.rs index 4e770310..9469e5e9 100644 --- a/src/handle.rs +++ b/src/handle.rs @@ -60,6 +60,16 @@ impl Handle { 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.