Skip to content

Commit

Permalink
Merge pull request #531 from salsa-rs/handle-into-inner
Browse files Browse the repository at this point in the history
Add Handle::into_inner method
  • Loading branch information
nikomatsakis authored Jul 27, 2024
2 parents 4952436 + c66f600 commit 8788180
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 8788180

Please sign in to comment.