More Send/Sync

This commit is contained in:
Nanopro
2020-02-17 21:26:32 +03:00
committed by GitHub
parent 6aaa7d279a
commit c070a5bbb7
2 changed files with 6 additions and 7 deletions

View File

@ -28,6 +28,8 @@ pub mod vulkan {
pub format: u32,
pub sample_count: u32,
}
unsafe impl Send for Texture{}
unsafe impl Sync for Texture{}
}
#[derive(Debug, Copy, Clone)]

View File

@ -52,9 +52,7 @@ pub unsafe fn init(ty: ApplicationType) -> Result<Context, InitError> {
sys::EVRInitError_VRInitError_Init_InterfaceNotFound,
));
}
Ok(Context {
live: Cell::new(true),
})
Ok(Context { live: AtomicBool::new(true) })
}
pub struct System(&'static sys::VR_IVRSystem_FnTable);
@ -67,9 +65,7 @@ pub struct Chaperone(&'static sys::VR_IVRChaperone_FnTable);
/// At most one of this object may exist at a time.
///
/// See safety notes in `init`.
pub struct Context {
live: Cell<bool>,
}
pub struct Context { live: AtomicBool }
fn load<T>(suffix: &[u8]) -> Result<*const T, InitError> {
let mut magic = Vec::from(b"FnTable:".as_ref());
@ -116,9 +112,10 @@ impl Context {
/// attempting to free graphics resources.
///
/// No calls to other OpenVR methods may be made after this has been called unless a new `Context` is first
/// constructed.
pub unsafe fn shutdown(&self) {
if self.live.replace(false) {
if self.live.swap(false, Ordering::Acquire) {
sys::VR_ShutdownInternal();
INITIALIZED.store(false, Ordering::Release);
}