private void add_peer(ICommPeer peer) { var peers = _peers; var newPeers = new List<ICommPeer>(peers); newPeers.Add(peer); _counters.Vcall_State_ActivePeers++; _peers = newPeers; }
// 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); }
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(); }
void IRepository.Remove(ICommPeer peer) { remove_peer(peer); }
void IRepository.Add(ICommPeer peer) { add_peer(peer); }
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); } }
// user arbitrary thread void IVcallSubsystem.Close(ICommPeer peer) { close_comm_peers(new[] {peer}); }