Skip to content

Add Supporting for PyAtomicRef<Option<_>> and PyAtomicRef<PyObject> #4286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 24, 2022

Conversation

qingshi163
Copy link
Contributor

No description provided.

@@ -214,7 +214,10 @@ impl<T: PyPayload> ToPyObject for PyRefExact<T> {
}
}

pub struct PyAtomicRef<T: PyObjectPayload>(PyAtomic<*mut Py<T>>);
pub struct PyAtomicRef<T> {
inner: PyAtomic<*mut i8>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inner: PyAtomic<*mut i8>,
inner: PyAtomic<*mut u8>,

it doesn't look important, but i've usually seen other code use u8 for this case. (to express void*)

Comment on lines 302 to 308
let old = unsafe { self.swap(opt_ref) };
if let Some(old) = old {
if let Some(frame) = vm.current_frame() {
frame.temporary_refs.lock().push(old.into());
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tiny style suggestion

Suggested change
let old = unsafe { self.swap(opt_ref) };
if let Some(old) = old {
if let Some(frame) = vm.current_frame() {
frame.temporary_refs.lock().push(old.into());
}
}
}
let Some(old) = unsafe { self.swap(opt_ref) } else {
return;
};
if let Some(frame) = vm.current_frame() {
frame.temporary_refs.lock().push(old.into());
}
}

@qingshi163 qingshi163 merged commit f54b555 into RustPython:main Nov 24, 2022
@qingshi163 qingshi163 deleted the atomicrefoption branch November 24, 2022 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants