rhai_dylib/module_resolvers/
mod.rs1#[cfg(feature = "libloading")]
3pub mod libloading;
4
5#[cfg(not(feature = "sync"))]
10pub type LockGuard<'a, T> = std::cell::Ref<'a, T>;
11
12#[cfg(not(feature = "sync"))]
14pub type LockGuardMut<'a, T> = std::cell::RefMut<'a, T>;
15
16#[cfg(feature = "sync")]
18#[allow(dead_code)]
19pub type LockGuard<'a, T> = std::sync::RwLockReadGuard<'a, T>;
20
21#[cfg(feature = "sync")]
23#[allow(dead_code)]
24pub type LockGuardMut<'a, T> = std::sync::RwLockWriteGuard<'a, T>;
25
26#[allow(dead_code)]
32pub fn locked_write<T>(value: &'_ rhai::Locked<T>) -> LockGuardMut<'_, T> {
33 #[cfg(not(feature = "sync"))]
34 return value.borrow_mut();
35
36 #[cfg(feature = "sync")]
37 return value.write().unwrap();
38}
39
40#[allow(dead_code)]
46pub fn locked_read<T>(value: &'_ rhai::Locked<T>) -> LockGuard<'_, T> {
47 #[cfg(not(feature = "sync"))]
48 return value.borrow();
49
50 #[cfg(feature = "sync")]
51 return value.read().unwrap();
52}