use std::cell::{Cell, RefCell};
thread_local! {
static LOCKED: Cell<bool> = const { Cell::new(true) };
static REQUESTS: RefCell<Vec<(*mut sys::IVEngineServer, bool)>> =
const { RefCell::new(Vec::new()) };
}
pub unsafe extern "C" fn lock_network_string_tables(
this: *mut sys::IVEngineServer,
lock: bool,
) -> bool {
REQUESTS.with_borrow_mut(|requests| requests.push((this, lock)));
LOCKED.replace(lock)
}
pub fn lock_requests() -> Vec<(*mut sys::IVEngineServer, bool)> {
REQUESTS.with_borrow(Clone::clone)
}
pub fn set_tables_locked(locked: bool) {
LOCKED.set(locked);
}
pub fn tables_locked() -> bool {
LOCKED.get()
}