Brunet.PathEdge.Close C# (CSharp) Method

Close() public method

public Close ( ) : bool
return bool
    public override bool Close() {
      _e.Close();
      return base.Close();
    }

Usage Example

Example #1
0
        /**
         * Handles Rrm TimeoutChecking as well as removing stale entries from the
         * _unannounced Edge dictionary.
         */
        protected void TimeoutCheck()
        {
            _rrm.TimeoutChecker(null, null);

            DateTime now  = DateTime.UtcNow;
            long     next = _next_check;

            if (next < now.Ticks)
            {
                // If someone else is checking it, let's just end it here
                long current = Interlocked.Exchange(ref _next_check, now.AddMinutes(5).Ticks);
                if (next != current)
                {
                    return;
                }
            }

            // Get the list of old edges
            DateTime    remove_timeout = now.AddMinutes(-5);
            List <Edge> to_close       = new List <Edge>();

            lock (_sync) {
                foreach (Edge e in _unannounced.Keys)
                {
                    if (e.CreatedDateTime < remove_timeout)
                    {
                        to_close.Add(e);
                    }
                }
            }

            // Close the Edges
            foreach (Edge e in to_close)
            {
                PathEdge pe = null;
                if (!_unannounced.TryGetValue(e, out pe))
                {
                    continue;
                }

                try {
                    pe.Close();
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                }
            }

            // Remove them from the _unannounced dictionary
            lock (_sync) {
                foreach (Edge e in to_close)
                {
                    _unannounced.Remove(e);
                }
            }
        }