MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / GILProtected

Class GILProtected

src/pythonrun.rs:157–159  ·  view source on GitHub ↗

Mutex-like wrapper object for data that is protected by the Python GIL. # Example ``` use std::cell::Cell; use cpython::{Python, GILProtected}; let data = GILProtected::new(Cell::new(0)); { let gil_guard = Python::acquire_gil(); let cell = data.get(gil_guard.python()); cell.set(cell.get() + 1); } ```

Source from the content-addressed store, hash-verified

155/// }
156/// ```
157pub struct GILProtected<T> {
158 data: T,
159}
160
161unsafe impl<T: Send> Send for GILProtected<T> {}
162

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected