Skip to content

Commit

Permalink
akkadotnet#1676 moved akka.util.internal.collections over to system.c…
Browse files Browse the repository at this point in the history
…ollections.immutable relatives.

Have depended upon current implementations enumerable over values collections being in ascending order following a load of tests on the collections i performed elsewhere.
This is not explicitly documented - but does follow the standard 'walk tree' behavior so is perhaps dependable.
  • Loading branch information
MrTortoise committed Feb 9, 2016
1 parent 83de693 commit 330dca0
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 1,362 deletions.
131 changes: 6 additions & 125 deletions src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1752,14 +1752,14 @@ namespace Akka.Actor.Internal
}
public abstract class ChildrenContainerBase : Akka.Actor.Internal.IChildrenContainer
{
protected ChildrenContainerBase(Akka.Util.Internal.Collections.IImmutableMap<string, Akka.Actor.Internal.IChildStats> children) { }
protected ChildrenContainerBase(System.Collections.Immutable.IImmutableDictionary<string, Akka.Actor.Internal.IChildStats> children) { }
public System.Collections.Generic.IReadOnlyList<Akka.Actor.IInternalActorRef> Children { get; }
protected Akka.Util.Internal.Collections.IImmutableMap<string, Akka.Actor.Internal.IChildStats> InternalChildren { get; }
protected System.Collections.Immutable.IImmutableDictionary<string, Akka.Actor.Internal.IChildStats> InternalChildren { get; }
public virtual bool IsNormal { get; }
public virtual bool IsTerminating { get; }
public System.Collections.Generic.IReadOnlyList<Akka.Actor.Internal.ChildRestartStats> Stats { get; }
public abstract Akka.Actor.Internal.IChildrenContainer Add(string name, Akka.Actor.Internal.ChildRestartStats stats);
protected void ChildStatsAppender(System.Text.StringBuilder sb, Akka.Util.Internal.Collections.IKeyValuePair<string, Akka.Actor.Internal.IChildStats> kvp, int index) { }
protected void ChildStatsAppender(System.Text.StringBuilder sb, System.Collections.Generic.KeyValuePair<string, Akka.Actor.Internal.IChildStats> kvp, int index) { }
public bool Contains(Akka.Actor.IActorRef actor) { }
public abstract Akka.Actor.Internal.IChildrenContainer Remove(Akka.Actor.IActorRef child);
public abstract Akka.Actor.Internal.IChildrenContainer Reserve(string name);
Expand Down Expand Up @@ -1831,7 +1831,7 @@ namespace Akka.Actor.Internal
public class NormalChildrenContainer : Akka.Actor.Internal.ChildrenContainerBase
{
public override Akka.Actor.Internal.IChildrenContainer Add(string name, Akka.Actor.Internal.ChildRestartStats stats) { }
public static Akka.Actor.Internal.IChildrenContainer Create(Akka.Util.Internal.Collections.IImmutableMap<string, Akka.Actor.Internal.IChildStats> children) { }
public static Akka.Actor.Internal.IChildrenContainer Create(System.Collections.Immutable.IImmutableDictionary<string, Akka.Actor.Internal.IChildStats> children) { }
public override Akka.Actor.Internal.IChildrenContainer Remove(Akka.Actor.IActorRef child) { }
public override Akka.Actor.Internal.IChildrenContainer Reserve(string name) { }
public override Akka.Actor.Internal.IChildrenContainer ShallDie(Akka.Actor.IActorRef actor) { }
Expand Down Expand Up @@ -1871,8 +1871,8 @@ namespace Akka.Actor.Internal
}
public class TerminatingChildrenContainer : Akka.Actor.Internal.ChildrenContainerBase
{
public TerminatingChildrenContainer(Akka.Util.Internal.Collections.IImmutableMap<string, Akka.Actor.Internal.IChildStats> children, Akka.Actor.IActorRef toDie, Akka.Actor.Internal.SuspendReason reason) { }
public TerminatingChildrenContainer(Akka.Util.Internal.Collections.IImmutableMap<string, Akka.Actor.Internal.IChildStats> children, Akka.Util.Internal.Collections.IImmutableSet<Akka.Actor.IActorRef> toDie, Akka.Actor.Internal.SuspendReason reason) { }
public TerminatingChildrenContainer(System.Collections.Immutable.IImmutableDictionary<string, Akka.Actor.Internal.IChildStats> children, Akka.Actor.IActorRef toDie, Akka.Actor.Internal.SuspendReason reason) { }
public TerminatingChildrenContainer(System.Collections.Immutable.IImmutableDictionary<string, Akka.Actor.Internal.IChildStats> children, System.Collections.Immutable.ImmutableHashSet<Akka.Actor.IActorRef> toDie, Akka.Actor.Internal.SuspendReason reason) { }
public override bool IsNormal { get; }
public override bool IsTerminating { get; }
public Akka.Actor.Internal.SuspendReason Reason { get; }
Expand Down Expand Up @@ -4841,12 +4841,6 @@ namespace Akka.Util.Internal
}
namespace Akka.Util.Internal.Collections
{
public class EmptyReadOnlyCollections<T>
{
public EmptyReadOnlyCollections() { }
public static System.Collections.Generic.IReadOnlyCollection<T> Collection { get; }
public static System.Collections.Generic.IReadOnlyList<T> List { get; }
}
public class static EnumeratorExtensions
{
public static Akka.Util.Internal.Collections.Iterator<T> Iterator<T>(this System.Collections.Generic.IEnumerable<T> enumerable) { }
Expand All @@ -4856,124 +4850,11 @@ namespace Akka.Util.Internal.Collections
Akka.Util.Internal.Collections.IBinaryTreeNode<TKey, TValue> Left { get; }
Akka.Util.Internal.Collections.IBinaryTreeNode<TKey, TValue> Right { get; }
}
public interface IImmutableMap<TKey, TValue>
where TKey : System.IComparable<>
{
System.Collections.Generic.IEnumerable<TKey> AllKeysMaxToMin { get; }
System.Collections.Generic.IEnumerable<TKey> AllKeysMinToMax { get; }
System.Collections.Generic.IEnumerable<Akka.Util.Internal.Collections.IKeyValuePair<TKey, TValue>> AllMaxToMin { get; }
System.Collections.Generic.IEnumerable<Akka.Util.Internal.Collections.IKeyValuePair<TKey, TValue>> AllMinToMax { get; }
System.Collections.Generic.IEnumerable<TValue> AllValuesMaxToMin { get; }
System.Collections.Generic.IEnumerable<TValue> AllValuesMinToMax { get; }
int Count { get; }
bool IsEmpty { get; }
TValue this[TKey key] { get; }
Akka.Util.Internal.Collections.IImmutableMap<TKey, TValue> Add(TKey key, TValue value);
Akka.Util.Internal.Collections.IImmutableMap<TKey, TValue> AddOrUpdate(TKey key, TValue value);
bool Contains(TKey key);
Akka.Util.Internal.Collections.IImmutableMap<TKey, TValue> Remove(TKey key);
bool TryAdd(TKey key, TValue value, out Akka.Util.Internal.Collections.IImmutableMap<, > newMap);
bool TryGet(TKey key, out TValue value);
bool TryRemove(TKey key, out Akka.Util.Internal.Collections.IImmutableMap<, > newMap);
}
public interface IImmutableSet<TValue> : System.Collections.Generic.IEnumerable<TValue>, System.Collections.IEnumerable
where TValue : System.IComparable<>
{
System.Collections.Generic.IEnumerable<TValue> AllMaxToMin { get; }
System.Collections.Generic.IEnumerable<TValue> AllMinToMax { get; }
int Count { get; }
bool IsEmpty { get; }
Akka.Util.Internal.Collections.IImmutableSet<TValue> Add(TValue value);
bool Contains(TValue value);
Akka.Util.Internal.Collections.IImmutableSet<TValue> Remove(TValue value);
Akka.Util.Internal.Collections.IImmutableSet<TValue> Remove(System.Collections.Generic.IEnumerable<TValue> values);
bool TryAdd(TValue value, out Akka.Util.Internal.Collections.IImmutableSet<> newMap);
bool TryRemove(TValue value, out Akka.Util.Internal.Collections.IImmutableSet<> newMap);
}
public interface IKeyValuePair<out TKey, out TValue>
{
TKey Key { get; }
TValue Value { get; }
}
public sealed class ImmutableAvlTree<TKey, TValue> : Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>
where TKey : System.IComparable<>
{
public static readonly Akka.Util.Internal.Collections.ImmutableAvlTree<TKey, TValue> Empty;
public Akka.Util.Internal.Collections.ImmutableAvlTree<TKey, TValue> Add(TKey key, TValue value) { }
public Akka.Util.Internal.Collections.ImmutableAvlTree<TKey, TValue> AddOrUpdate(TKey key, TValue value) { }
public Akka.Util.Internal.Collections.ImmutableAvlTree<TKey, TValue> Remove(TKey key) { }
public bool TryRemove(TKey key, out Akka.Util.Internal.Collections.ImmutableAvlTree<, > newMap) { }
}
public abstract class ImmutableAvlTreeBase<TKey, TValue> : System.Collections.Generic.IEnumerable<Akka.Util.Internal.Collections.IKeyValuePair<TKey, TValue>>, System.Collections.IEnumerable
where TKey : System.IComparable<>
{
protected ImmutableAvlTreeBase() { }
protected ImmutableAvlTreeBase(Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.Node node) { }
public System.Collections.Generic.IEnumerable<TKey> AllKeysMaxToMin { get; }
public System.Collections.Generic.IEnumerable<TKey> AllKeysMinToMax { get; }
public System.Collections.Generic.IEnumerable<Akka.Util.Internal.Collections.IKeyValuePair<TKey, TValue>> AllMaxToMin { get; }
public System.Collections.Generic.IEnumerable<Akka.Util.Internal.Collections.IKeyValuePair<TKey, TValue>> AllMinToMax { get; }
public System.Collections.Generic.IEnumerable<TValue> AllValuesMaxToMin { get; }
public System.Collections.Generic.IEnumerable<TValue> AllValuesMinToMax { get; }
public int Count { get; }
public bool IsEmpty { get; }
public TValue this[TKey key] { get; }
public Akka.Util.Internal.Collections.IBinaryTreeNode<TKey, TValue> Root { get; }
public bool Contains(TKey key) { }
public System.Collections.Generic.IEnumerator<Akka.Util.Internal.Collections.IKeyValuePair<TKey, TValue>> GetEnumerator() { }
public override string ToString() { }
protected bool TryAdd(TKey key, TValue value, out Akka.Util.Internal.Collections.ImmutableAvlTreeBase<, >.Node newNode, Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.AddOperation typeOfAdd) { }
protected static bool TryAdd(Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.Node node, TKey key, TValue value, out Akka.Util.Internal.Collections.ImmutableAvlTreeBase<, >.Node newNode, Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.AddOperation typeOfAdd) { }
public bool TryGet(TKey key, out TValue value) { }
protected bool TryRemove(TKey key, out Akka.Util.Internal.Collections.ImmutableAvlTreeBase<, >.Node newNode) { }
protected enum AddOperation<TKey, TValue>
where TKey : System.IComparable<>
{
Add = 0,
AddOrUpdate = 1,
AddOnlyUnique = 2,
}
public class Node<TKey, TValue> : Akka.Util.Internal.Collections.IBinaryTreeNode<TKey, TValue>, Akka.Util.Internal.Collections.IKeyValuePair<TKey, TValue>
where TKey : System.IComparable<>
{
public Node(TKey key, TValue value, Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.Node left, Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.Node right) { }
public int Count { get; }
public int Height { get; }
public TKey Key { get; }
public Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.Node Left { get; }
public Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>.Node Right { get; }
public TValue Value { get; }
public override string ToString() { }
}
}
public class static ImmutableSetExtensions
{
public static Akka.Util.Internal.Collections.IImmutableSet<TValue> Remove<TValue>(this Akka.Util.Internal.Collections.IImmutableSet<TValue> set, System.Predicate<TValue> itemsToRemove)
where TValue : System.IComparable<> { }
}
public sealed class ImmutableTreeMap<TKey, TValue> : Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TKey, TValue>, Akka.Util.Internal.Collections.IImmutableMap<TKey, TValue>
where TKey : System.IComparable<>
{
public static readonly Akka.Util.Internal.Collections.ImmutableTreeMap<TKey, TValue> Empty;
public Akka.Util.Internal.Collections.ImmutableTreeMap<TKey, TValue> Add(TKey key, TValue value) { }
public Akka.Util.Internal.Collections.ImmutableTreeMap<TKey, TValue> AddOrUpdate(TKey key, TValue value) { }
public Akka.Util.Internal.Collections.ImmutableTreeMap<TKey, TValue> Remove(TKey key) { }
public bool TryAdd(TKey key, TValue value, out Akka.Util.Internal.Collections.ImmutableTreeMap<, > newTreeMap) { }
public bool TryRemove(TKey key, out Akka.Util.Internal.Collections.ImmutableTreeMap<, > newMap) { }
}
public class ImmutableTreeSet<TValue> : Akka.Util.Internal.Collections.ImmutableAvlTreeBase<TValue, TValue>, Akka.Util.Internal.Collections.IImmutableSet<TValue>, System.Collections.Generic.IEnumerable<TValue>, System.Collections.IEnumerable
where TValue : System.IComparable<>
{
public static readonly Akka.Util.Internal.Collections.ImmutableTreeSet<TValue> Empty;
public Akka.Util.Internal.Collections.ImmutableTreeSet<TValue> Add(TValue value) { }
public Akka.Util.Internal.Collections.ImmutableTreeSet<TValue> AddOrUpdate(TValue value) { }
public static Akka.Util.Internal.Collections.ImmutableTreeSet<TValue> Create(TValue value, params TValue[] values) { }
public static Akka.Util.Internal.Collections.ImmutableTreeSet<TValue> Create(System.Collections.Generic.IEnumerable<TValue> values) { }
public Akka.Util.Internal.Collections.ImmutableTreeSet<TValue> Remove(TValue value) { }
public Akka.Util.Internal.Collections.ImmutableTreeSet<TValue> Remove(System.Collections.Generic.IEnumerable<TValue> values) { }
public bool TryAdd(TValue value, out Akka.Util.Internal.Collections.ImmutableTreeSet<> newTreeMap) { }
public bool TryRemove(TValue value, out Akka.Util.Internal.Collections.ImmutableTreeSet<> newMap) { }
}
public class Iterator<T>
{
public Iterator(System.Collections.Generic.IEnumerable<T> enumerator) { }
Expand Down
4 changes: 4 additions & 0 deletions src/core/Akka.Remote/Akka.Remote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Web" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/core/Akka.Remote/RemoteDeploymentWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Dispatch;
using Akka.Dispatch.SysMsg;
using Akka.Util.Internal.Collections;

namespace Akka.Remote
{
Expand All @@ -24,8 +24,8 @@ namespace Akka.Remote
internal class RemoteDeploymentWatcher : ActorBase, IRequiresMessageQueue<IUnboundedMessageQueueSemantics>
{

private readonly IImmutableMap<IActorRef, IInternalActorRef> _supervisors =
ImmutableTreeMap<IActorRef, IInternalActorRef>.Empty;
private readonly IImmutableDictionary<IActorRef, IInternalActorRef> _supervisors =
ImmutableDictionary<IActorRef, IInternalActorRef>.Empty;
protected override bool Receive(object message)
{
if (message == null)
Expand All @@ -39,7 +39,7 @@ protected override bool Receive(object message)
}).With<Terminated>(t =>
{
IInternalActorRef supervisor;
if (_supervisors.TryGet(t.ActorRef, out supervisor))
if (_supervisors.TryGetValue(t.ActorRef, out supervisor))
{
supervisor.SendSystemMessage(new DeathWatchNotification(t.ActorRef, t.ExistenceConfirmed, t.AddressTerminated), supervisor);
_supervisors.Remove(t.ActorRef);
Expand Down
6 changes: 3 additions & 3 deletions src/core/Akka.Remote/RemoteSystemDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Akka.Actor;
using Akka.Actor.Internal;
using Akka.Dispatch.SysMsg;
using Akka.Event;
using Akka.Util;
using Akka.Util.Internal;
using Akka.Util.Internal.Collections;

namespace Akka.Remote
{
Expand Down Expand Up @@ -184,7 +184,7 @@ protected void OnReceive(object message, IActorRef sender)
{
_terminating.Locked(() =>
{
IImmutableSet<IActorRef> children;
IImmutableSet<IActorRef> children;
if (_parent2Children.TryRemove(parent,out children))
{
foreach (var c in children)
Expand Down Expand Up @@ -303,7 +303,7 @@ private bool AddChildParentNeedsWatch(IActorRef parent, IActorRef child)
const bool weDontHaveTailRecursion = true;
while (weDontHaveTailRecursion)
{
if (_parent2Children.TryAdd(parent, ImmutableTreeSet<IActorRef>.Create(child)))
if (_parent2Children.TryAdd(parent, ImmutableHashSet<IActorRef>.Empty.Add(child)))
return true; //child was successfully added

IImmutableSet<IActorRef> children;
Expand Down
1 change: 1 addition & 0 deletions src/core/Akka.Remote/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<packages>
<package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
<package id="Helios" version="1.4.1" targetFramework="net45" />
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
</packages>
2 changes: 0 additions & 2 deletions src/core/Akka.Tests/Akka.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@
<Compile Include="Util\ContinuousEnumeratorSpec.cs" />
<Compile Include="Util\Internal\Collections\IteratorTests.cs" />
<Compile Include="Util\Internal\InterlockedSpinTests.cs" />
<Compile Include="Util\Internal\Collections\ImmutableAvlTreeMapTests.cs" />
<Compile Include="Util\Internal\Collections\ImmutableAvlTreeTests.cs" />
<Compile Include="Util\PatternSpec.cs" />
<Compile Include="Util\SwitchTests.cs" />
<Compile Include="Util\TypeExtensionsTests.cs" />
Expand Down

This file was deleted.

Loading

0 comments on commit 330dca0

Please sign in to comment.