Skip to main content

luaur_common/methods/
thread_context_thread_context_time_trace_alt_b.rs

1//! Source: `Common/include/Luau/TimeTrace.h:74-80` (hand-ported)
2//! C++ `~ThreadContext() { if (!events.empty()) flushEvents(); releaseThread(*globalContext, this); }`.
3use crate::functions::release_thread::release_thread;
4use crate::records::thread_context::ThreadContext;
5
6impl ThreadContext {
7    pub fn drop(&mut self) {
8        if !self.events.is_empty() {
9            self.flush_events();
10        }
11
12        // `releaseThread(*globalContext, this)` — the singleton guards its own
13        // mutable state behind a Mutex, so a shared `&` suffices. Clone the Arc
14        // first so we can also pass `self` as the thread pointer.
15        let global_context = self.global_context.clone();
16        release_thread(&global_context, self as *mut ThreadContext);
17    }
18}