MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / with_context

Function with_context

flow-rs/src/loader/python/context.rs:20–29  ·  view source on GitHub ↗
(py: Python, f: F)

Source from the content-addressed store, hash-verified

18}
19
20pub fn with_context<F, R>(py: Python, f: F) -> R
21where
22 F: FnOnce() -> R + Send,
23 R: Send,
24{
25 let id = CTX.with(|ctx| ctx.borrow_mut().store());
26 let r = py.allow_threads(f);
27 CTX.with(|ctx| ctx.borrow_mut().restore(id));
28 r
29}
30
31struct Context {
32 thread: *mut ffi::PyThreadState,

Callers 7

yield_nowFunction · 0.85
sleepFunction · 0.85
joinFunction · 0.85
waitMethod · 0.85
sendMethod · 0.85
recvMethod · 0.85
batch_recvMethod · 0.85

Calls 2

storeMethod · 0.80
restoreMethod · 0.80

Tested by

no test coverage detected