MCPcopy Index your code
hub / github.com/RustPython/RustPython / detach_thread

Function detach_thread

crates/vm/src/vm/thread.rs:187–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

185/// Transition ATTACHED → DETACHED (like `_PyThreadState_Detach`).
186#[cfg(all(unix, feature = "threading"))]
187fn detach_thread() {
188 CURRENT_THREAD_SLOT.with(|slot| {
189 if let Some(s) = slot.borrow().as_ref() {
190 match s.state.compare_exchange(
191 THREAD_ATTACHED,
192 THREAD_DETACHED,
193 Ordering::AcqRel,
194 Ordering::Acquire,
195 ) {
196 Ok(_) => {}
197 Err(THREAD_DETACHED) => {
198 debug_assert!(false, "detach called while already DETACHED");
199 return;
200 }
201 Err(state) => {
202 debug_assert!(false, "unexpected thread state in detach: {state}");
203 return;
204 }
205 }
206 super::stw_trace(format_args!("detach ATTACHED->DETACHED"));
207 }
208 });
209}
210
211/// Temporarily transition the current thread ATTACHED → DETACHED while
212/// running `f`, then re-attach afterwards. This allows `stop_the_world`

Callers 1

allow_threadsFunction · 0.85

Calls 4

stw_traceFunction · 0.85
withMethod · 0.80
as_refMethod · 0.45
borrowMethod · 0.45

Tested by

no test coverage detected