Exemple #1
0
 private void PublicationOnlyViaConstructor(LazyHelper initializer)
 {
     PublicationOnly(initializer, CreateViaDefaultConstructor());
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="System.Lazy{T}"/>
 /// class that uses <typeparamref name="T"/>'s default constructor and a specified thread-safety mode.
 /// </summary>
 /// <param name="isThreadSafe">true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.
 /// </param>
 public Lazy(bool isThreadSafe) :
     this(null, LazyHelper.GetModeFromIsThreadSafe(isThreadSafe), useDefaultConstructor : true)
 {
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="System.Lazy{T}"/> class
 /// that uses a specified initialization function and a specified thread-safety mode.
 /// </summary>
 /// <param name="valueFactory">
 /// The <see cref="System.Func{T}"/> invoked to produce the lazily-initialized value when it is needed.
 /// </param>
 /// <param name="isThreadSafe">true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.
 /// </param>
 /// <exception cref="System.ArgumentNullException"><paramref name="valueFactory"/> is
 /// a null reference (Nothing in Visual Basic).</exception>
 public Lazy(Func <T> valueFactory, bool isThreadSafe) :
     this(valueFactory, LazyHelper.GetModeFromIsThreadSafe(isThreadSafe), useDefaultConstructor : false)
 {
 }
Exemple #4
0
 private static T CreateViaDefaultConstructor() => LazyHelper.CreateViaDefaultConstructor <T>();
Exemple #5
0
 private void ViaConstructor()
 {
     m_value = CreateViaDefaultConstructor();
     _state  = null; // volatile write, must occur after setting _value
 }
Exemple #6
0
 private static T CreateViaDefaultConstructor()
 {
     return((T)LazyHelper.CreateViaDefaultConstructor(typeof(T)));
 }
Exemple #7
0
 internal static bool GetIsValueFaulted(LazyHelper state) => state?._exceptionDispatch != null;
Exemple #8
0
 public static Lazy <T> HookValueFactory <T>(this Lazy <T> lazy, Func <Func <T>, T> valueFactory)
 {
     LazyHelper <T> .HookValueFactory(lazy, valueFactory); return(lazy);
 }