@@ -119,7 +119,7 @@ impl Thread {
119
119
120
120
let old_lifecycle = inner
121
121
. lifecycle
122
- . swap ( LIFECYCLE_EXITED_OR_FINISHED_OR_JOIN_FINALIZE , Ordering :: Release ) ;
122
+ . swap ( LIFECYCLE_EXITED_OR_FINISHED_OR_JOIN_FINALIZE , Ordering :: AcqRel ) ;
123
123
124
124
match old_lifecycle {
125
125
LIFECYCLE_DETACHED => {
@@ -129,9 +129,9 @@ impl Thread {
129
129
130
130
// In this case, `*p_inner`'s ownership has been moved to
131
131
// us, and we are responsible for dropping it. The acquire
132
- // ordering is not necessary because the parent thread made
133
- // no memory access needing synchronization since the call
134
- // to `acre_tsk `.
132
+ // ordering ensures that the swap operation that wrote
133
+ // `LIFECYCLE_DETACHED` happens-before `Box::from_raw(
134
+ // p_inner) `.
135
135
// Safety: See above.
136
136
let _ = unsafe { Box :: from_raw ( p_inner) } ;
137
137
@@ -267,15 +267,15 @@ impl Drop for Thread {
267
267
let inner = unsafe { self . p_inner . as_ref ( ) } ;
268
268
269
269
// Detach the thread.
270
- match inner. lifecycle . swap ( LIFECYCLE_DETACHED_OR_JOINED , Ordering :: Acquire ) {
270
+ match inner. lifecycle . swap ( LIFECYCLE_DETACHED_OR_JOINED , Ordering :: AcqRel ) {
271
271
LIFECYCLE_INIT => {
272
272
// [INIT → DETACHED]
273
273
// When the time comes, the child will figure out that no
274
274
// one will ever join it.
275
275
// The ownership of `*p_inner` is moved to the child thread.
276
- // However, the release ordering is not necessary because we
277
- // made no memory access needing synchronization since the call
278
- // to `acre_tsk `.
276
+ // The release ordering ensures that the above swap operation on
277
+ // `lifecycle` happens-before the child thread's
278
+ // `Box::from_raw(p_inner) `.
279
279
}
280
280
LIFECYCLE_FINISHED => {
281
281
// [FINISHED → JOINED]
0 commit comments