File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1455,7 +1455,15 @@ impl error::Error for ParseLevelError {}
1455
1455
///
1456
1456
/// If a logger has not been set, a no-op implementation is returned.
1457
1457
pub fn logger ( ) -> & ' static dyn Log {
1458
- if STATE . load ( Ordering :: SeqCst ) != INITIALIZED {
1458
+ // Acquire memory ordering guarantees that current thread would see any
1459
+ // memory writes that happened before store of the value
1460
+ // into `STATE` with memory ordering `Release` or stronger.
1461
+ //
1462
+ // Since the value `INITIALIZED` is written only after `LOGGER` was
1463
+ // initialized, observing it after `Acquire` load here makes both
1464
+ // write to the `LOGGER` static and initialization of the logger
1465
+ // internal state synchronized with current thread.
1466
+ if STATE . load ( Ordering :: Acquire ) != INITIALIZED {
1459
1467
static NOP : NopLogger = NopLogger ;
1460
1468
& NOP
1461
1469
} else {
You can’t perform that action at this time.
0 commit comments