internal static void PushActorRefToStack(LocalActorRef actorRef) { InterlockedSpin.Swap(ref _stack, st => st == null ? ImmutableStack.Create(actorRef) : st.Push(actorRef)); }
internal static void PopActorAndMarkerFromStack() { InterlockedSpin.Swap(ref _stack, st => st == null ? null : st.Peek() == null // if first item is null, i.e. a marker ? st.Pop().Pop() // then pop that value, : st.Pop()); // otherwise pop only the actor }
public static void Clear_ForTestingONLY() { InterlockedSpin.Swap(ref _stack, st => st.Clear()); InterlockedSpin.Swap(ref _stack, st => st.Clear()); }
private void UpdateChildrenCollection(Func <ChildrenCollection, ChildrenCollection> updater) { #pragma warning disable 420 //Ok to disregard from CS0420 "a reference to a volatile field will not be treated as volatile" as we're using interlocked underneath, see http://msdn.microsoft.com/en-us/library/4bw5ewxy.aspx InterlockedSpin.Swap(ref _childrenDoNotCallMeDirectly, updater); #pragma warning restore 420 }