Akka.Interfaced.SlimServer.ActorBoundChannelBase.Close C# (CSharp) Method

Close() protected method

protected Close ( ) : void
return void
        protected void Close()
        {
            if (_closed)
                return;

            _closed = true;

            // Send channel-closed notification message to bound actors

            lock (_boundActorLock)
            {
                foreach (var i in _boundActorMap)
                {
                    var notification = (ActorBindingFlags)(((int)i.Value.BindingFlags) & (0x3 << 1));
                    if (notification == ActorBindingFlags.CloseThenDefault)
                    {
                        notification = i.Value.IsChildActor
                            ? ActorBindingFlags.CloseThenStop
                            : ActorBindingFlags.CloseThenNothing;
                    }

                    switch (notification)
                    {
                        case ActorBindingFlags.CloseThenStop:
                            i.Value.Actor.Tell(InterfacedPoisonPill.Instance);
                            break;

                        case ActorBindingFlags.CloseThenNotification:
                            i.Value.Actor.Tell(new NotificationMessage
                            {
                                InvokePayload = new IActorBoundChannelObserver_PayloadTable.ChannelClose_Invoke
                                {
                                    channel = Self.Cast<ActorBoundChannelRef>(),
                                    tag = _tag
                                },
                            });
                            break;
                    }
                }

                // after sending notification, waiting for all children to stop.
                // but in this case, there is no child so stop now.

                if (_boundActorMap.Any(i => i.Value.IsChildActor) == false)
                    Self.Tell(InterfacedPoisonPill.Instance);
            }
        }