Skip to content
Snippets Groups Projects
Commit a1908eb0 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

rust-cpython: mark PySharedState as Sync so &'PySharedState can be Send

The goal is to store &'static PySharedState in $leaked struct, which allows
us to move the $leaked struct out of the macro. Currently, it depends on
inner.$data_member(py), which can't be generalized.

PySharedState is Sync because any mutation or read operation is synchronized
by the Python GIL, py: Python<'a>, which should guarantee that &'PySharedState
can be sent to another thread.
parent 1c675c5f
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,10 @@
mutably_borrowed: Cell<bool>,
}
// &PySharedState can be Send because any access to inner cells is
// synchronized by the GIL.
unsafe impl Sync for PySharedState {}
impl PySharedState {
pub fn borrow_mut<'a, T>(
&'a self,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment