File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
src/uucore/src/lib/features Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,18 @@ impl UError for UptimeError {
3838 }
3939}
4040
41+ // setup_localization() stores its state in thread local storage,
42+ // so every thread that might format uptime strings has to call it once.
43+ // Track that per thread so our helpers can lazily initialize
44+ // the locale only once per thread.
4145thread_local ! {
4246 static LOCALE_READY : Cell <bool > = const { Cell :: new( false ) } ;
4347}
4448
49+ // Lazily initialize the uptime localization for the current thread, marking it
50+ // done even if a sibling thread already ran setup_localization() so we avoid
51+ // propagating the "already initialized" error and only log unexpected failures
52+ // in debug builds.
4553fn ensure_uptime_locale ( ) {
4654 LOCALE_READY . with ( |ready| {
4755 if ready. get ( ) {
You can’t perform that action at this time.
0 commit comments