-
Notifications
You must be signed in to change notification settings - Fork 961
DateTime: use more relaxed ordering constraints #6027
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -604,12 +604,12 @@ pub const PyDateTime_CAPSULE_NAME: &CStr = c"datetime.datetime_CAPI"; | |
| /// `PyDateTime_IMPORT` is called | ||
| #[inline] | ||
| pub unsafe fn PyDateTimeAPI() -> *mut PyDateTime_CAPI { | ||
| PyDateTimeAPI_impl.load(core::sync::atomic::Ordering::SeqCst) | ||
| PyDateTimeAPI_impl.load(Ordering::Acquire) | ||
| } | ||
|
|
||
| /// Populates the `PyDateTimeAPI` object | ||
| pub unsafe fn PyDateTime_IMPORT() { | ||
| if PyDateTimeAPI_impl.load(Ordering::SeqCst).is_null() { | ||
| if PyDateTimeAPI_impl.load(Ordering::Relaxed).is_null() { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we just need to check if the value is null, "relaxed" is enough |
||
| // PyPy expects the C-API to be initialized via PyDateTime_Import, so trying to use | ||
| // `PyCapsule_Import` will behave unexpectedly in pypy. | ||
| #[cfg(PyPy)] | ||
|
|
@@ -628,8 +628,8 @@ pub unsafe fn PyDateTime_IMPORT() { | |
| let _ = PyDateTimeAPI_impl.compare_exchange( | ||
| ptr::null_mut(), | ||
| py_datetime_c_api, | ||
| Ordering::SeqCst, | ||
| Ordering::SeqCst, | ||
| Ordering::Release, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need to acquire any state here on success (it's done by Similarly on error we don't need to expose anything (no visible change to the other thread) and |
||
| Ordering::Relaxed, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to expose any state here so "acquire" is fine