comparison rust/hg-cpython/src/dirstate/dirs_multiset.rs @ 44073:f8c114f20d2d

rust-cpython: require GIL to borrow immutable reference from PySharedRefCell Since the inner value may be leaked, we probably need GIL to guarantee that there's no data race. inner(py).borrow() is replaced with inner_shared(py).borrow(), which basically means any PySharedRefCell data should be accessed through PySharedRef wrapper.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 Sep 2019 17:15:50 +0900
parents ffc1fbd7d1f5
children
comparison
equal deleted inserted replaced
44072:ffc1fbd7d1f5 44073:f8c114f20d2d
98 unsafe { leaked_ref.map(py, |o| o.iter()) }, 98 unsafe { leaked_ref.map(py, |o| o.iter()) },
99 ) 99 )
100 } 100 }
101 101
102 def __contains__(&self, item: PyObject) -> PyResult<bool> { 102 def __contains__(&self, item: PyObject) -> PyResult<bool> {
103 Ok(self.inner(py).borrow().contains(HgPath::new( 103 Ok(self.inner_shared(py).borrow().contains(HgPath::new(
104 item.extract::<PyBytes>(py)?.data(py).as_ref(), 104 item.extract::<PyBytes>(py)?.data(py).as_ref(),
105 ))) 105 )))
106 } 106 }
107 }); 107 });
108 108