mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-02 09:46:06 +00:00
Add Handle::into_inner method
This commit is contained in:
parent
e4ce917f6e
commit
c66f600c06
1 changed files with 10 additions and 0 deletions
|
@ -60,6 +60,16 @@ impl<Db: HasStorage> Handle<Db> {
|
||||||
Arc::get_mut(self.db_mut()).expect("other threads remain active despite cancellation")
|
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
|
// ANCHOR: cancel_other_workers
|
||||||
/// Sets cancellation flag and blocks until all other workers with access
|
/// Sets cancellation flag and blocks until all other workers with access
|
||||||
/// to this storage have completed.
|
/// to this storage have completed.
|
||||||
|
|
Loading…
Reference in a new issue