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 format: u32,
pub sample_count: u32, pub sample_count: u32,
} }
unsafe impl Send for Texture{}
unsafe impl Sync for Texture{}
} }
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]

View File

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