From 7cdfdda3e179cb2174d4451bb5b14e08e36750ba Mon Sep 17 00:00:00 2001 From: HCanber Date: Tue, 31 Mar 2015 20:56:09 +0200 Subject: [PATCH] Rename ChildrenContainer > IChildrenContainer #652 --- src/core/Akka/Actor/ActorCell.Children.cs | 20 +++++++++---------- .../Internal/ChildrenContainer.cs | 13 ++++++------ .../Internal/ChildrenContainerBase.cs | 12 +++++------ .../Internal/EmptyChildrenContainer.cs | 16 +++++++-------- .../Internal/NormalChildrenContainer.cs | 12 +++++------ .../Internal/TerminatedChildrenContainer.cs | 8 ++++---- .../Internal/TerminatingChildrenContainer.cs | 12 +++++------ src/core/Akka/Akka.csproj.DotSettings | 1 + 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/core/Akka/Actor/ActorCell.Children.cs b/src/core/Akka/Actor/ActorCell.Children.cs index 38a10df5aab..1972e41a95e 100644 --- a/src/core/Akka/Actor/ActorCell.Children.cs +++ b/src/core/Akka/Actor/ActorCell.Children.cs @@ -9,16 +9,16 @@ namespace Akka.Actor { public partial class ActorCell { - private ChildrenContainer _childrenContainerDoNotCallMeDirectly = EmptyChildrenContainer.Instance; + private IChildrenContainer _childrenContainerDoNotCallMeDirectly = EmptyChildrenContainer.Instance; private long _nextRandomNameDoNotCallMeDirectly; [Obsolete("Use ChildrenContainer instead", true)] - private ChildrenContainer ChildrenRefs + private IChildrenContainer ChildrenRefs { get { return ChildrenContainer; } } - private ChildrenContainer ChildrenContainer + private IChildrenContainer ChildrenContainer { get { return _childrenContainerDoNotCallMeDirectly; } //TODO: Hmm do we need memory barriers here??? } @@ -104,7 +104,7 @@ private void SwapChildrenRefs() { } /// /// A function that returns a new container. /// The third value of the tuple that returned. - private TReturn UpdateChildrenRefs(Func> updater) + private TReturn UpdateChildrenRefs(Func> updater) { return InterlockedSpin.ConditionallySwap(ref _childrenContainerDoNotCallMeDirectly, updater); } @@ -117,7 +117,7 @@ private TReturn UpdateChildrenRefs(Func /// A function that returns a new container. /// The new updated - private ChildrenContainer UpdateChildrenRefs(Func updater) + private IChildrenContainer UpdateChildrenRefs(Func updater) { return InterlockedSpin.Swap(ref _childrenContainerDoNotCallMeDirectly, updater); } @@ -146,18 +146,18 @@ public ChildRestartStats InitChild(IInternalActorRef actor) if (old != null) { //Do not update. Return old - return new Tuple(false, cc, old); + return new Tuple(false, cc, old); } if (stats is ChildNameReserved) { var crs = new ChildRestartStats(actor); var updatedContainer = cc.Add(name, crs); //Update (if it's still cc) and return the new crs - return new Tuple(true, updatedContainer, crs); + return new Tuple(true, updatedContainer, crs); } } //Do not update. Return null - return new Tuple(false, cc, null); + return new Tuple(false, cc, null); }); } @@ -168,10 +168,10 @@ protected bool SetChildrenTerminationReason(SuspendReason reason) var c = cc as TerminatingChildrenContainer; if (c != null) //The arguments says: Update; with a new reason; and return true - return new Tuple(true, c.CreateCopyWithReason(reason), true); + return new Tuple(true, c.CreateCopyWithReason(reason), true); //The arguments says:Do NOT update; any container will do since it wont be updated; return false - return new Tuple(false, cc, false); + return new Tuple(false, cc, false); }); } diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainer.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainer.cs index 6e996234078..db19e225ec8 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainer.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainer.cs @@ -2,18 +2,17 @@ namespace Akka.Actor.Internal { - // ReSharper disable once InconsistentNaming - public interface ChildrenContainer + public interface IChildrenContainer { - ChildrenContainer Add(string name, ChildRestartStats stats); - ChildrenContainer Remove(IActorRef child); + IChildrenContainer Add(string name, ChildRestartStats stats); + IChildrenContainer Remove(IActorRef child); bool TryGetByName(string name, out ChildStats stats); bool TryGetByRef(IActorRef actor, out ChildRestartStats stats); IReadOnlyList Children { get; } IReadOnlyList Stats { get; } - ChildrenContainer ShallDie(IActorRef actor); - ChildrenContainer Reserve(string name); - ChildrenContainer Unreserve(string name); + IChildrenContainer ShallDie(IActorRef actor); + IChildrenContainer Reserve(string name); + IChildrenContainer Unreserve(string name); bool IsTerminating { get; } bool IsNormal { get; } bool Contains(IActorRef actor); diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainerBase.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainerBase.cs index ea6260e2896..efe8867cab6 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainerBase.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildrenContainerBase.cs @@ -5,7 +5,7 @@ namespace Akka.Actor.Internal { - public abstract class ChildrenContainerBase : ChildrenContainer + public abstract class ChildrenContainerBase : IChildrenContainer { private readonly IImmutableMap _children; @@ -16,11 +16,11 @@ protected ChildrenContainerBase(IImmutableMap children) public virtual bool IsTerminating { get { return false; } } public virtual bool IsNormal { get { return true; } } - public abstract ChildrenContainer Add(string name, ChildRestartStats stats); - public abstract ChildrenContainer Remove(IActorRef child); - public abstract ChildrenContainer Reserve(string name); - public abstract ChildrenContainer ShallDie(IActorRef actor); - public abstract ChildrenContainer Unreserve(string name); + public abstract IChildrenContainer Add(string name, ChildRestartStats stats); + public abstract IChildrenContainer Remove(IActorRef child); + public abstract IChildrenContainer Reserve(string name); + public abstract IChildrenContainer ShallDie(IActorRef actor); + public abstract IChildrenContainer Unreserve(string name); public IReadOnlyList Children { diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/EmptyChildrenContainer.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/EmptyChildrenContainer.cs index 44bd79c5a44..c9cad3863f9 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/EmptyChildrenContainer.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/EmptyChildrenContainer.cs @@ -6,25 +6,25 @@ namespace Akka.Actor.Internal /// /// This is the empty container, shared among all leaf actors. /// - public class EmptyChildrenContainer : ChildrenContainer + public class EmptyChildrenContainer : IChildrenContainer { private static readonly ImmutableTreeMap _emptyStats = ImmutableTreeMap.Empty; - private static readonly ChildrenContainer _instance = new EmptyChildrenContainer(); + private static readonly IChildrenContainer _instance = new EmptyChildrenContainer(); protected EmptyChildrenContainer() { //Intentionally left blank } - public static ChildrenContainer Instance { get { return _instance; } } + public static IChildrenContainer Instance { get { return _instance; } } - public virtual ChildrenContainer Add(string name, ChildRestartStats stats) + public virtual IChildrenContainer Add(string name, ChildRestartStats stats) { var newMap = _emptyStats.Add(name, stats); return NormalChildrenContainer.Create(newMap); } - public ChildrenContainer Remove(IActorRef child) + public IChildrenContainer Remove(IActorRef child) { return this; } @@ -50,17 +50,17 @@ public bool Contains(IActorRef actor) public IReadOnlyList Stats { get { return EmptyReadOnlyCollections.List; } } - public ChildrenContainer ShallDie(IActorRef actor) + public IChildrenContainer ShallDie(IActorRef actor) { return this; } - public virtual ChildrenContainer Reserve(string name) + public virtual IChildrenContainer Reserve(string name) { return NormalChildrenContainer.Create(_emptyStats.Add(name, ChildNameReserved.Instance)); } - public ChildrenContainer Unreserve(string name) + public IChildrenContainer Unreserve(string name) { return this; } diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/NormalChildrenContainer.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/NormalChildrenContainer.cs index dc043c98630..e5e9073a69d 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/NormalChildrenContainer.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/NormalChildrenContainer.cs @@ -16,35 +16,35 @@ private NormalChildrenContainer(IImmutableMap children) { } - public static ChildrenContainer Create(IImmutableMap children) + public static IChildrenContainer Create(IImmutableMap children) { if (children.IsEmpty) return EmptyChildrenContainer.Instance; return new NormalChildrenContainer(children); } - public override ChildrenContainer Add(string name, ChildRestartStats stats) + public override IChildrenContainer Add(string name, ChildRestartStats stats) { return Create(InternalChildren.AddOrUpdate(name, stats)); } - public override ChildrenContainer Remove(IActorRef child) + public override IChildrenContainer Remove(IActorRef child) { return Create(InternalChildren.Remove(child.Path.Name)); } - public override ChildrenContainer ShallDie(IActorRef actor) + public override IChildrenContainer ShallDie(IActorRef actor) { return new TerminatingChildrenContainer(InternalChildren, actor, SuspendReason.UserRequest.Instance); } - public override ChildrenContainer Reserve(string name) + public override IChildrenContainer Reserve(string name) { if (InternalChildren.Contains(name)) throw new InvalidActorNameException(string.Format("Actor name \"{0}\" is not unique!", name)); return new NormalChildrenContainer(InternalChildren.AddOrUpdate(name, ChildNameReserved.Instance)); } - public override ChildrenContainer Unreserve(string name) + public override IChildrenContainer Unreserve(string name) { ChildStats stats; if (InternalChildren.TryGet(name, out stats) && (stats is ChildNameReserved)) diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatedChildrenContainer.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatedChildrenContainer.cs index f8d8f354630..a250bca2946 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatedChildrenContainer.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatedChildrenContainer.cs @@ -9,20 +9,20 @@ namespace Akka.Actor.Internal /// public class TerminatedChildrenContainer : EmptyChildrenContainer { - private static readonly ChildrenContainer _instance = new TerminatedChildrenContainer(); + private static readonly IChildrenContainer _instance = new TerminatedChildrenContainer(); private TerminatedChildrenContainer() { //Intentionally left blank } - public new static ChildrenContainer Instance { get { return _instance; } } + public new static IChildrenContainer Instance { get { return _instance; } } - public override ChildrenContainer Add(string name, ChildRestartStats stats) + public override IChildrenContainer Add(string name, ChildRestartStats stats) { return this; } - public override ChildrenContainer Reserve(string name) + public override IChildrenContainer Reserve(string name) { throw new InvalidOperationException("Cannot reserve actor name '" + name + "': already terminated"); } diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatingChildrenContainer.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatingChildrenContainer.cs index e9a5dd1446b..bd078395058 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatingChildrenContainer.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/TerminatingChildrenContainer.cs @@ -33,13 +33,13 @@ public TerminatingChildrenContainer(IImmutableMap children, public SuspendReason Reason { get { return _reason; } } - public override ChildrenContainer Add(string name, ChildRestartStats stats) + public override IChildrenContainer Add(string name, ChildRestartStats stats) { var newMap = InternalChildren.AddOrUpdate(name, stats); return new TerminatingChildrenContainer(newMap, _toDie, _reason); } - public override ChildrenContainer Remove(IActorRef child) + public override IChildrenContainer Remove(IActorRef child) { var set = _toDie.Remove(child); if (set.IsEmpty) @@ -50,12 +50,12 @@ public override ChildrenContainer Remove(IActorRef child) return new TerminatingChildrenContainer(InternalChildren.Remove(child.Path.Name), set, _reason); } - public override ChildrenContainer ShallDie(IActorRef actor) + public override IChildrenContainer ShallDie(IActorRef actor) { return new TerminatingChildrenContainer(InternalChildren, _toDie.Add(actor), _reason); } - public override ChildrenContainer Reserve(string name) + public override IChildrenContainer Reserve(string name) { if (_reason is SuspendReason.Termination) throw new InvalidOperationException(string.Format("Cannot reserve actor name\"{0}\". Is terminating.", name)); if (InternalChildren.Contains(name)) @@ -64,7 +64,7 @@ public override ChildrenContainer Reserve(string name) return new TerminatingChildrenContainer(InternalChildren.AddOrUpdate(name, ChildNameReserved.Instance), _toDie, _reason); } - public override ChildrenContainer Unreserve(string name) + public override IChildrenContainer Unreserve(string name) { ChildStats stats; if (!InternalChildren.TryGet(name, out stats)) @@ -99,7 +99,7 @@ public override string ToString() return sb.ToString(); } - public ChildrenContainer CreateCopyWithReason(SuspendReason reason) + public IChildrenContainer CreateCopyWithReason(SuspendReason reason) { return new TerminatingChildrenContainer(InternalChildren, _toDie, reason); } diff --git a/src/core/Akka/Akka.csproj.DotSettings b/src/core/Akka/Akka.csproj.DotSettings index cd54c84504a..ba8e842233a 100644 --- a/src/core/Akka/Akka.csproj.DotSettings +++ b/src/core/Akka/Akka.csproj.DotSettings @@ -1,6 +1,7 @@  True True + True True True True \ No newline at end of file