public CacheNeedle(Func <T> valueFactory, T target, bool trackResurrection, bool cacheExceptions) : base(target, trackResurrection) { if (valueFactory == null) { throw new ArgumentNullException("valueFactory"); } _valueFactory = valueFactory; if (cacheExceptions) { _valueFactory = () => { try { return(valueFactory.Invoke()); } catch (Exception exc) { _valueFactory = FuncHelper.GetThrowFunc <T>(exc); throw; } }; } _waitHandle = new StructNeedle <ManualResetEventSlim>(new ManualResetEventSlim(false)); }
public Promise(Exception exception) { Exception = exception; _hashCode = exception.GetHashCode(); _waitHandle = new ManualResetEventSlim(true); _onCompleted = new StrongDelegateCollection(true); }
public Promise(bool done) { Exception = null; _hashCode = base.GetHashCode(); if (!done) { _waitHandle = new ManualResetEventSlim(false); } }
public bool Equals(StructNeedle <T> other) { var value = other.Value; if (other.IsAlive) { return(Equals(value)); } return(!IsAlive); }
public CacheNeedle(Func <T> valueFactory, T target, bool trackResurrection) : base(target, trackResurrection) { if (valueFactory == null) { throw new ArgumentNullException("valueFactory"); } _valueFactory = valueFactory; _waitHandle = new StructNeedle <ManualResetEventSlim>(new ManualResetEventSlim(false)); }
public CacheNeedle(Func <T> valueFactory) : base(default(T)) { if (valueFactory == null) { throw new ArgumentNullException("valueFactory"); } _valueFactory = valueFactory; _waitHandle = new StructNeedle <ManualResetEventSlim>(new ManualResetEventSlim(false)); }
public bool Equals(StructNeedle <T> other) { var leftValue = Value; if (IsAlive) { var rightValue = other.Value; return(other.IsAlive && EqualityComparer <T> .Default.Equals(leftValue, rightValue)); } return(!other.IsAlive); }
private static bool EqualsExtracted(StructNeedle <T> left, StructNeedle <T> right) { var leftValue = left.Value; if (left.IsAlive) { var rightValue = right.Value; return(right.IsAlive && EqualityComparer <T> .Default.Equals(leftValue, rightValue)); } return(!right.IsAlive); }
public Promise(bool done) { Exception = null; _hashCode = base.GetHashCode(); if (!done) { _waitHandle = new ManualResetEventSlim(false); } _onCompleted = new StrongDelegateCollection(true); }
public CacheNeedle() : base(default(T)) { _valueFactory = null; _waitHandle = new StructNeedle <ManualResetEventSlim>(null); }
public CacheNeedle(T target) : base(target) { _valueFactory = null; _waitHandle = new StructNeedle <ManualResetEventSlim>(null); }
public CacheNeedle(Func <T> valueFactory, T target) : base(target) { _valueFactory = valueFactory ?? throw new ArgumentNullException(nameof(valueFactory)); _waitHandle = new StructNeedle <ManualResetEventSlim>(new ManualResetEventSlim(false)); }
public bool Equals(StructNeedle <T> other) { return(EqualsExtracted(this, other)); }
public Promise(Exception exception) { Exception = exception; _hashCode = exception.GetHashCode(); _waitHandle = new ManualResetEventSlim(true); }