You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it's wrong to use LazyThreadSafetyMode.NONE since it is unsafe for general use:
No locks are used to synchronize access and initialization of a Lazy instance value. If the instance is accessed from multiple threads, its behavior is unspecified.
This mode should not be used unless the Lazy instance is guaranteed never to be initialized from more than one thread.
The LazyThreadSafetyMode.PUBLICATION is actually safe for this use-case:
Initializer function can be called several times on concurrent access to an uninitialized Lazy instance value, but only one computed value will be used as the value of a Lazy instance and will be visible by all threads.
Thanks.
The text was updated successfully, but these errors were encountered:
Thank you for issue 🙂
However, Google typically uses a backing field format that doesn't involve any synchronization at all.
The Lazy property format for the icon was introduced by me for more compact code without synchronization because all icons are loaded on the main thread (later if compose introduce async recompositions the situation can be changed).
If you have real case with synchronization issue, please share it.
I think it's wrong to use
LazyThreadSafetyMode.NONE
since it is unsafe for general use:The
LazyThreadSafetyMode.PUBLICATION
is actually safe for this use-case:Thanks.
The text was updated successfully, but these errors were encountered: