Skip to content

Instantly share code, notes, and snippets.

@izmajlowiczl
Created April 28, 2017 11:51
Show Gist options
  • Save izmajlowiczl/566e493d5179cedd1601cc073a55dd9c to your computer and use it in GitHub Desktop.
Save izmajlowiczl/566e493d5179cedd1601cc073a55dd9c to your computer and use it in GitHub Desktop.
/**
* Specifies how a [Lazy] instance synchronizes access among multiple threads.
*/
public enum class LazyThreadSafetyMode {
/**
* Locks are used to ensure that only a single thread can initialize the [Lazy] instance.
*/
SYNCHRONIZED,
/**
* 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.
*/
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.
*
* 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.
*/
NONE,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment