Skip to content

Commit 01df0a2

Browse files
committed
Address review: use seq-cst atomics for initialized flags
Not performance critical, so use the default ordering rather than acquire/release.
1 parent abae231 commit 01df0a2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Include/internal/pycore_runtime.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,27 @@ _PyRuntimeState_SetFinalizing(_PyRuntimeState *runtime, PyThreadState *tstate) {
5656
}
5757
}
5858

59-
// Release on store, acquire on load: a thread that reads initialized=1
60-
// is guaranteed to observe all writes from the initialization sequence.
59+
// Atomic so a thread that reads initialized=1 observes all writes
60+
// from the initialization sequence (gh-146302).
6161

6262
static inline int
6363
_PyRuntimeState_GetCoreInitialized(_PyRuntimeState *runtime) {
64-
return _Py_atomic_load_int_acquire(&runtime->core_initialized);
64+
return _Py_atomic_load_int(&runtime->core_initialized);
6565
}
6666

6767
static inline void
6868
_PyRuntimeState_SetCoreInitialized(_PyRuntimeState *runtime, int initialized) {
69-
_Py_atomic_store_int_release(&runtime->core_initialized, initialized);
69+
_Py_atomic_store_int(&runtime->core_initialized, initialized);
7070
}
7171

7272
static inline int
7373
_PyRuntimeState_GetInitialized(_PyRuntimeState *runtime) {
74-
return _Py_atomic_load_int_acquire(&runtime->initialized);
74+
return _Py_atomic_load_int(&runtime->initialized);
7575
}
7676

7777
static inline void
7878
_PyRuntimeState_SetInitialized(_PyRuntimeState *runtime, int initialized) {
79-
_Py_atomic_store_int_release(&runtime->initialized, initialized);
79+
_Py_atomic_store_int(&runtime->initialized, initialized);
8080
}
8181

8282

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
:c:func:`Py_IsInitialized` no longer returns true until initialization has
22
fully completed, including import of the :mod:`site` module. The underlying
3-
runtime flags now use atomic operations with acquire/release memory ordering.
3+
runtime flags now use atomic operations.

0 commit comments

Comments
 (0)