Skip to content

Commit 8788180

Browse files
authored
Merge pull request #531 from salsa-rs/handle-into-inner
Add Handle::into_inner method
2 parents 4952436 + c66f600 commit 8788180

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/handle.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ impl<Db: HasStorage> Handle<Db> {
6060
Arc::get_mut(self.db_mut()).expect("other threads remain active despite cancellation")
6161
}
6262

63+
/// Returns the inner database, consuming the handle.
64+
///
65+
/// If other handles are active, this method sets the cancellation flag
66+
/// and blocks until they are dropped.
67+
pub fn into_inner(mut self) -> Db {
68+
self.cancel_others();
69+
Arc::into_inner(self.db.take().unwrap())
70+
.expect("other threads remain active despite cancellation")
71+
}
72+
6373
// ANCHOR: cancel_other_workers
6474
/// Sets cancellation flag and blocks until all other workers with access
6575
/// to this storage have completed.

0 commit comments

Comments
 (0)