We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd4f0c3 commit ef1d292Copy full SHA for ef1d292
vm/src/object/ext.rs
@@ -245,6 +245,19 @@ pub struct PyAtomicRef<T> {
245
_phantom: PhantomData<T>,
246
}
247
248
+impl<T> Drop for PyAtomicRef<T> {
249
+ fn drop(&mut self) {
250
+ // SAFETY: We are dropping the atomic reference, so we can safely
251
+ // release the pointer.
252
+ unsafe {
253
+ let ptr = Radium::swap(&self.inner, null_mut(), Ordering::Relaxed);
254
+ if let Some(ptr) = NonNull::<PyObject>::new(ptr.cast()) {
255
+ let _: PyObjectRef = PyObjectRef::from_raw(ptr);
256
+ }
257
258
259
+}
260
+
261
cfg_if::cfg_if! {
262
if #[cfg(feature = "threading")] {
263
unsafe impl<T: Send + PyObjectPayload> Send for PyAtomicRef<T> {}
0 commit comments