1
use std::sync::LazyLock;
2
use std::sync::Mutex;
3
use std::sync::MutexGuard;
4

            
5
pub type GlobalLockGuard = MutexGuard<'static, ()>;
6

            
7
/// A global lock for non thread safe FFI functions.
8
1044
pub fn lock_global() -> GlobalLockGuard {
9
1044
    GLOBAL_MUTEX.lock().expect("Failed to lock GLOBAL_MUTEX")
10
1044
}
11

            
12
/// This is the global mutex used to guard non thread safe FFI functions.
13
264
pub(crate) static GLOBAL_MUTEX: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));