Exemplo n.º 1
0
        private void add_peer(ICommPeer peer)
        {
            var peers = _peers;

            var newPeers = new List<ICommPeer>(peers);
            newPeers.Add(peer);

            _counters.Vcall_State_ActivePeers++;

            _peers = newPeers;
        }
Exemplo n.º 2
0
        // user arbitrary thread
        void IEngine.ClosePeer(int timeout, ICommPeer peer, IDoneEvent observer)
        {
            lock (_self.mutex)
            {
                _self.repo.Remove(peer);
                _self.counters.Vcall_Event_CloseCommPeer++;
            }

            _self.resolver.Cancel(peer.Tag);

            peer.Stop(timeout, observer);
        }
Exemplo n.º 3
0
        private void remove_peer(ICommPeer peerToRemove)
        {
            var peers = _peers;

            var newPeers =
                from peer in peers
                where !ReferenceEquals(peer, peerToRemove)
                select peer;

            _counters.Vcall_State_ActivePeers--;

            _peers = newPeers.ToList();
        }
Exemplo n.º 4
0
 void IRepository.Remove(ICommPeer peer)
 {
     remove_peer(peer);
 }
Exemplo n.º 5
0
 void IRepository.Add(ICommPeer peer)
 {
     add_peer(peer);
 }
Exemplo n.º 6
0
        private void close_comm_peers(ICommPeer[] peers)
        {
            int timeout = _self.vconfig.Timeouts.PeerClosing;
            int wcfTimeout = _self.vconfig.Timeouts.WcfHostClosing;

            var observer = DoneEvent.New(peers.Length);

            foreach (var peer in peers)
            {
                trace("closing peer.{0}", peer.Tag);
                _engine.ClosePeer(wcfTimeout, peer, observer);
            }

            if (observer.Wait(timeout) == false)
            {
                int notReadyCount = observer.NotReadyCount;

                lock (_self.mutex)
                    _self.counters.Vcall_Error_CloseCommPeer += notReadyCount;

                if (notReadyCount == 1)
                    warn("Failed to stop peer.{0} (timeout={1})", peers[0].Tag, timeout);
                else
                    warn("Failed to stop {0} peers (timeout={1})", notReadyCount, timeout);
            }
            else
            {
                if (peers.Length == 1)
                    trace("peer.{0} is closed", peers[0].Tag);
                else
                    trace("{0} peers are closed", peers.Length);
            }
        }
Exemplo n.º 7
0
 // user arbitrary thread
 void IVcallSubsystem.Close(ICommPeer peer)
 {
     close_comm_peers(new[] {peer});
 }