private void PublicationOnlyViaConstructor(LazyHelper initializer) { PublicationOnly(initializer, CreateViaDefaultConstructor()); }
/// <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) { }
/// <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) { }
private static T CreateViaDefaultConstructor() => LazyHelper.CreateViaDefaultConstructor <T>();
private void ViaConstructor() { m_value = CreateViaDefaultConstructor(); _state = null; // volatile write, must occur after setting _value }
private static T CreateViaDefaultConstructor() { return((T)LazyHelper.CreateViaDefaultConstructor(typeof(T))); }
internal static bool GetIsValueFaulted(LazyHelper state) => state?._exceptionDispatch != null;
public static Lazy <T> HookValueFactory <T>(this Lazy <T> lazy, Func <Func <T>, T> valueFactory) { LazyHelper <T> .HookValueFactory(lazy, valueFactory); return(lazy); }