luaur-common 0.1.3

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
18
//! Source: `Common/include/Luau/TimeTrace.h:74-80` (hand-ported)
//! C++ `~ThreadContext() { if (!events.empty()) flushEvents(); releaseThread(*globalContext, this); }`.
use crate::functions::release_thread::release_thread;
use crate::records::thread_context::ThreadContext;

impl ThreadContext {
    pub fn drop(&mut self) {
        if !self.events.is_empty() {
            self.flush_events();
        }

        // `releaseThread(*globalContext, this)` — the singleton guards its own
        // mutable state behind a Mutex, so a shared `&` suffices. Clone the Arc
        // first so we can also pass `self` as the thread pointer.
        let global_context = self.global_context.clone();
        release_thread(&global_context, self as *mut ThreadContext);
    }
}