unregister adapters like all other resources

This commit is contained in:
teoxoy 2024-07-02 20:06:03 +02:00 committed by Teodor Tanasoaia
parent 5b2e78da45
commit eb0eb342cf
2 changed files with 1 additions and 18 deletions

View File

@ -1043,16 +1043,7 @@ impl Global {
api_log!("Adapter::drop {adapter_id:?}");
let hub = A::hub(self);
let mut adapters_locked = hub.adapters.write();
let free = match adapters_locked.get(adapter_id) {
Ok(adapter) => Arc::strong_count(adapter) == 1,
Err(_) => true,
};
if free {
hub.adapters
.unregister_locked(adapter_id, &mut *adapters_locked);
}
hub.adapters.unregister(adapter_id);
}
}

View File

@ -111,14 +111,6 @@ impl<T: StorageItem> Registry<T> {
pub(crate) fn write<'a>(&'a self) -> RwLockWriteGuard<'a, Storage<T>> {
self.storage.write()
}
pub(crate) fn unregister_locked(
&self,
id: Id<T::Marker>,
storage: &mut Storage<T>,
) -> Option<Arc<T>> {
self.identity.free(id);
storage.remove(id)
}
pub(crate) fn force_replace_with_error(&self, id: Id<T::Marker>) {
let mut storage = self.storage.write();
storage.remove(id);