Docs: clarifications on LazyThreadSafetyMode

This commit is contained in:
Ilya Gorbunov
2017-11-15 11:53:31 +03:00
parent 0768e7404b
commit 9de6dd814b
+4 -4
View File
@@ -81,7 +81,7 @@ public fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = SynchronizedLaz
public inline operator fun <T> Lazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value
/**
* Specifies how a [Lazy] instance synchronizes access among multiple threads.
* Specifies how a [Lazy] instance synchronizes initialization among multiple threads.
*/
public enum class LazyThreadSafetyMode {
@@ -92,14 +92,14 @@ public enum class LazyThreadSafetyMode {
/**
* Initializer function can be called several times on concurrent access to uninitialized [Lazy] instance value,
* but only first returned value will be used as the value of [Lazy] instance.
* but only the first returned value will be used as the value of [Lazy] instance.
*/
PUBLICATION,
/**
* No locks are used to synchronize the access to the [Lazy] instance value; if the instance is accessed from multiple threads, its behavior is undefined.
* No locks are used to synchronize an access to the [Lazy] instance value; if the instance is accessed from multiple threads, its behavior is undefined.
*
* This mode should be used only when high performance is crucial and the [Lazy] instance is guaranteed never to be initialized from more than one thread.
* This mode should not be used unless the [Lazy] instance is guaranteed never to be initialized from more than one thread.
*/
NONE,
}