mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
rusticl/core: don't take a lock while dropping Context
We have exclusive access in Drop, so we can use `get_mut` instead of having to `lock`. Since that borrows `self` mutably but `call` also needs to borrow `self`, we `take` the Vec with callbacks out of `self` so the mutable borrow can end before running `call`. Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25669>
This commit is contained in:
parent
54c74164a8
commit
8b6b405a01
1 changed files with 5 additions and 6 deletions
|
|
@ -15,6 +15,7 @@ use std::alloc::Layout;
|
|||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
use std::mem;
|
||||
use std::os::raw::c_void;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
|
@ -203,11 +204,9 @@ impl Context {
|
|||
|
||||
impl Drop for Context {
|
||||
fn drop(&mut self) {
|
||||
self.dtors
|
||||
.lock()
|
||||
.unwrap()
|
||||
.drain(..)
|
||||
.rev()
|
||||
.for_each(|cb| cb.call(self));
|
||||
let cbs = mem::take(self.dtors.get_mut().unwrap());
|
||||
for cb in cbs.into_iter().rev() {
|
||||
cb.call(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue