Skip to content

Commit

Permalink
added todo for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
maximv committed Feb 12, 2021
1 parent 461525c commit 28b53e4
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/DryIoc/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11764,6 +11764,7 @@ public interface IScope : IEnumerable<IScope>, IDisposable
// Creates, stores, and returns created item
// object GetOrAdd(int id, CreateScopedValue createValue, int disposalOrder = 0);

// todo: @v5 @obsolete split the method into the one with disposalOrder and with the one without
/// Create the value via `FactoryDelegate` passing the `IResolverContext`
object GetOrAddViaFactoryDelegate(int id, FactoryDelegate createValue, IResolverContext r, int disposalOrder = 0);

Expand Down Expand Up @@ -11909,21 +11910,6 @@ private object TryGetOrAdd(ref ImMap<object> map, int id, CreateScopedValue crea
return otherItemRef.Value != Scope.NoItem ? otherItemRef.Value : Scope.WaitForItemIsSet(otherItemRef);
}

// todo: @api @perf designing the better ImMap API returning the present item without GetSurePresentEntry call
// var itemRef = new ImMapEntry<object>(id, Scope.NoItem);
// var oldMap = map;
// var oldRefOrNewMap = oldMap.GetOrAddEntry(id, itemRef);
// if (oldRefOrNewMap is ImMapEntry<object> oldRef && oldMap != ImMap<object>.Empty)
// return oldRef.Value != Scope.NoItem ? oldRef.Value : Scope.WaitForItemIsSet(oldRef);

// if (Interlocked.CompareExchange(ref map, oldRefOrNewMap, oldMap) != oldMap)
// {
// oldRefOrNewMap = Ref.SwapAndGetNewValue(ref map, itemRef, (x, i) => x.AddOrKeepEntry(i));
// var otherItemRef = oldRefOrNewMap.GetSurePresentEntry(id);
// if (otherItemRef != itemRef)
// return otherItemRef.Value != Scope.NoItem ? otherItemRef.Value : Scope.WaitForItemIsSet(otherItemRef);
// }

object result = null;
#if SUPPORTS_SPIN_WAIT
itemRef.Value = result = createValue();
Expand Down Expand Up @@ -11982,6 +11968,21 @@ internal object TryGetOrAddViaFactoryDelegate(int id, FactoryDelegate createValu
return otherItemRef.Value != NoItem ? otherItemRef.Value : WaitForItemIsSet(otherItemRef);
}

// todo: @api @perf designing the better ImMap API returning the present item without GetSurePresentEntry call
// var itemRef = new ImMapEntry<object>(id, Scope.NoItem);
// var oldMap = map;
// var oldRefOrNewMap = oldMap.GetOrAddEntry(id, itemRef);
// if (oldRefOrNewMap is ImMapEntry<object> oldRef && oldMap != ImMap<object>.Empty)
// return oldRef.Value != Scope.NoItem ? oldRef.Value : Scope.WaitForItemIsSet(oldRef);

// if (Interlocked.CompareExchange(ref map, oldRefOrNewMap, oldMap) != oldMap)
// {
// oldRefOrNewMap = Ref.SwapAndGetNewValue(ref map, itemRef, (x, i) => x.AddOrKeepEntry(i));
// var otherItemRef = oldRefOrNewMap.GetSurePresentEntry(id);
// if (otherItemRef != itemRef)
// return otherItemRef.Value != Scope.NoItem ? otherItemRef.Value : Scope.WaitForItemIsSet(otherItemRef);
// }

object result = null;
#if SUPPORTS_SPIN_WAIT
itemRef.Value = result = createValue(r);
Expand Down

0 comments on commit 28b53e4

Please sign in to comment.