mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Changed to less restrictive memory ordering
This commit is contained in:
parent
267e7d8b4c
commit
6c991cc2cd
@ -24,16 +24,16 @@ impl EcsAccessManager {
|
|||||||
// pointer will never be corrupted during the execution of the function!
|
// pointer will never be corrupted during the execution of the function!
|
||||||
pub fn execute_with<T>(&self, world: &World, func: impl FnOnce() -> T) -> T {
|
pub fn execute_with<T>(&self, world: &World, func: impl FnOnce() -> T) -> T {
|
||||||
self.ecs_pointer
|
self.ecs_pointer
|
||||||
.store(world as *const _ as *mut _, Ordering::SeqCst);
|
.store(world as *const _ as *mut _, Ordering::Relaxed);
|
||||||
let out = func();
|
let out = func();
|
||||||
self.ecs_pointer
|
self.ecs_pointer
|
||||||
.store(std::ptr::null_mut::<_>(), Ordering::SeqCst);
|
.store(std::ptr::null_mut::<_>(), Ordering::Relaxed);
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self) -> Option<&World> {
|
pub fn get(&self) -> Option<&World> {
|
||||||
// ptr::as_ref will automatically check for null
|
// ptr::as_ref will automatically check for null
|
||||||
unsafe { self.ecs_pointer.load(Ordering::SeqCst).as_ref() }
|
unsafe { self.ecs_pointer.load(Ordering::Relaxed).as_ref() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user