pub trait SharedGetMutStorage<T>: UnprotectedStorage<T> {
    // Required method
    unsafe fn shared_get_mut(
        &self,
        id: Index
    ) -> <Self as UnprotectedStorage<T>>::AccessMut<'_>;
}
Expand description

Used by the framework to mutably access components in contexts where exclusive access to the storage is not possible.

Required Methods§

source

unsafe fn shared_get_mut( &self, id: Index ) -> <Self as UnprotectedStorage<T>>::AccessMut<'_>

Gets mutable access to the the data associated with an Index.

This is unsafe because the external set used to protect this storage is absent and because it doesn’t protect against concurrent calls from multiple threads and aliasing must manually be managed.

Safety

May only be called after a call to insert with id and no following call to remove with id or to clean.

A mask should keep track of those states, and an id being contained in the tracking mask is sufficient to call this method.

There must be no extant aliasing references to this component (i.e. obtained with the same id). Additionally, references obtained from methods on this type that take &self (e.g. SliceAccess::as_slice, Tracked::channel) must no longer be alive when shared_get_mut is called and these methods must not be called while the references returned here are alive. An exception is made for UnprotectedStorage::get as long as the live references it has returned do not alias with live references returned here.

Essentially, the unsafe code calling this must hold exclusive access of the storage at some level to ensure only known code is calling &self methods during the usage of this method and the references it produces.

Unless this type implements DistinctStorage, calling this from multiple threads at once is unsound.

Implementors§