luaur-common 0.1.1

Foundational data structures and flags for the luaur Luau-in-Rust toolchain.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::type_aliases::thread_context_provider::ThreadContextProvider;

pub fn thread_context_provider() -> &'static mut ThreadContextProvider {
    static mut HANDLER: ThreadContextProvider = {
        extern "C" fn default_provider() -> *mut crate::records::thread_context::ThreadContext {
            core::ptr::null_mut()
        }
        default_provider
    };

    // Safety: In the original C++, this is a function-local static.
    // While C++11 guarantees thread-safe initialization for statics,
    // it does not guarantee thread-safe access to the object itself.
    // Luau's TimeTrace usage of this global provider is typically
    // configured once at startup or in a single-threaded context.
    unsafe { &mut HANDLER }
}