Skip to content

Commit

Permalink
Rename ChildrenContainer > IChildrenContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
HCanber committed Mar 31, 2015
1 parent 1c4e8fe commit 7cdfdda
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 47 deletions.
20 changes: 10 additions & 10 deletions src/core/Akka/Actor/ActorCell.Children.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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???
}
Expand Down Expand Up @@ -104,7 +104,7 @@ private void SwapChildrenRefs() { }
/// </summary>
/// <param name="updater">A function that returns a new container.</param>
/// <returns>The third value of the tuple that <paramref name="updater"/> returned.</returns>
private TReturn UpdateChildrenRefs<TReturn>(Func<ChildrenContainer, Tuple<bool, ChildrenContainer, TReturn>> updater)
private TReturn UpdateChildrenRefs<TReturn>(Func<IChildrenContainer, Tuple<bool, IChildrenContainer, TReturn>> updater)
{
return InterlockedSpin.ConditionallySwap(ref _childrenContainerDoNotCallMeDirectly, updater);
}
Expand All @@ -117,7 +117,7 @@ private TReturn UpdateChildrenRefs<TReturn>(Func<ChildrenContainer, Tuple<bool,
/// </summary>
/// <param name="updater">A function that returns a new container.</param>
/// <returns>The new updated <see cref="ChildrenContainer"/></returns>
private ChildrenContainer UpdateChildrenRefs(Func<ChildrenContainer, ChildrenContainer> updater)
private IChildrenContainer UpdateChildrenRefs(Func<IChildrenContainer, IChildrenContainer> updater)
{
return InterlockedSpin.Swap(ref _childrenContainerDoNotCallMeDirectly, updater);
}
Expand Down Expand Up @@ -146,18 +146,18 @@ public ChildRestartStats InitChild(IInternalActorRef actor)
if (old != null)
{
//Do not update. Return old
return new Tuple<bool, ChildrenContainer, ChildRestartStats>(false, cc, old);
return new Tuple<bool, IChildrenContainer, ChildRestartStats>(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<bool, ChildrenContainer, ChildRestartStats>(true, updatedContainer, crs);
return new Tuple<bool, IChildrenContainer, ChildRestartStats>(true, updatedContainer, crs);
}
}
//Do not update. Return null
return new Tuple<bool, ChildrenContainer, ChildRestartStats>(false, cc, null);
return new Tuple<bool, IChildrenContainer, ChildRestartStats>(false, cc, null);
});
}

Expand All @@ -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<bool, ChildrenContainer, bool>(true, c.CreateCopyWithReason(reason), true);
return new Tuple<bool, IChildrenContainer, bool>(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<bool, ChildrenContainer, bool>(false, cc, false);
return new Tuple<bool, IChildrenContainer, bool>(false, cc, false);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IInternalActorRef> Children { get; }
IReadOnlyList<ChildRestartStats> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Akka.Actor.Internal
{
public abstract class ChildrenContainerBase : ChildrenContainer
public abstract class ChildrenContainerBase : IChildrenContainer
{
private readonly IImmutableMap<string, ChildStats> _children;

Expand All @@ -16,11 +16,11 @@ protected ChildrenContainerBase(IImmutableMap<string, ChildStats> 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<IInternalActorRef> Children
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ namespace Akka.Actor.Internal
/// <summary>
/// This is the empty container, shared among all leaf actors.
/// </summary>
public class EmptyChildrenContainer : ChildrenContainer
public class EmptyChildrenContainer : IChildrenContainer
{
private static readonly ImmutableTreeMap<string, ChildStats> _emptyStats = ImmutableTreeMap<string, ChildStats>.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;
}
Expand All @@ -50,17 +50,17 @@ public bool Contains(IActorRef actor)

public IReadOnlyList<ChildRestartStats> Stats { get { return EmptyReadOnlyCollections<ChildRestartStats>.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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@ private NormalChildrenContainer(IImmutableMap<string, ChildStats> children)
{
}

public static ChildrenContainer Create(IImmutableMap<string, ChildStats> children)
public static IChildrenContainer Create(IImmutableMap<string, ChildStats> 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ namespace Akka.Actor.Internal
/// </summary>
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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public TerminatingChildrenContainer(IImmutableMap<string, ChildStats> 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)
Expand All @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/core/Akka/Akka.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=actor_005Ccancellation/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Actor_005CChildrenContainer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=actor_005Cchildrencontainer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=actor_005Cscheduler/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Actor_005CStash/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Util_005CDurations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 comments on commit 7cdfdda

Please sign in to comment.