A LogSubscriberInternal that collects logs
Exemplo n.º 1
0
        /// <summary>
        /// Recalculates the entire routing table on a separate thread.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CalculateRoutingTable(object sender, EventArgs <ScheduledTaskRunningReason> e)
        {
            lock (m_syncRoot)
            {
                //Some other thread won on the race condition.
                if (RoutingTablesValid)
                {
                    return;
                }

                var subscribers = new List <LogSubscriberInternal>(m_subscribers.Count);
                m_subscribers.RemoveWhere(x =>
                {
                    LogSubscriberInternal subscriber = (LogSubscriberInternal)x.Target;
                    if (subscriber != null)
                    {
                        subscribers.Add(subscriber);
                        return(false);
                    }
                    return(true);
                });

                foreach (var pub in m_allPublishers)
                {
                    CalculateRoutingTableForPublisherSync(subscribers, pub);
                }
                RoutingTablesValid = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a type topic on a specified type.
        /// </summary>
        /// <param name="type">the type to create the topic from</param>
        /// <returns></returns>
        public LogPublisherInternal CreateType(Type type)
        {
            if ((object)type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            LogPublisherInternal publisher;

            lock (m_syncRoot)
            {
                if (!m_typeIndexCache.TryGetValue(type, out publisher))
                {
                    publisher = new LogPublisherInternal(this, type);
                    m_typeIndexCache.Add(type, publisher);
                    if (!m_disposing)
                    {
                        m_allPublishers.Add(publisher);
                        var lst = new List <LogSubscriberInternal>();
                        foreach (var logSubscriberInternal in m_subscribers)
                        {
                            LogSubscriberInternal target = logSubscriberInternal.Target as LogSubscriberInternal;
                            if (target != null)
                            {
                                lst.Add(target);
                            }
                        }
                        CalculateRoutingTableForPublisherSync(lst, publisher);
                    }
                }
            }
            return(publisher);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a <see cref="LogSubscriber"/> that can subscribe to log messages.
 /// </summary>
 /// <returns></returns>
 public LogSubscriberInternal CreateSubscriber()
 {
     lock (m_syncRoot)
     {
         if (m_disposing)
         {
             return(LogSubscriberInternal.DisposedSubscriber);
         }
         var s = new LogSubscriberInternal(RecalculateRoutingTable);
         m_subscribers.Add(s.Reference);
         return(s);
     }
 }
Exemplo n.º 4
0
 public void Add(MessageAttributeFilter filter, LogSubscriberInternal subscriber)
 {
     Routes.Add(Tuple.Create(filter, subscriber.Reference));
     Append(filter);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a <see cref="LogSubscriber"/>
 /// </summary>
 internal LogSubscriber(LogSubscriberInternal subscriber)
 {
     m_subscriber = subscriber;
 }
 static LogSubscriberInternal()
 {
     DisposedSubscriber = new LogSubscriberInternal(null);
     DisposedSubscriber.Dispose();
 }
Exemplo n.º 7
0
 static LogSubscriberInternal()
 {
     DisposedSubscriber = new LogSubscriberInternal(null);
     DisposedSubscriber.Dispose();
 }
 public void Add(MessageAttributeFilter filter, LogSubscriberInternal subscriber)
 {
     Routes.Add(Tuple.Create(filter, subscriber.Reference));
     Append(filter);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a <see cref="LogSubscriber"/> that can subscribe to log messages.
 /// </summary>
 /// <returns></returns>
 public LogSubscriberInternal CreateSubscriber()
 {
     lock (m_syncRoot)
     {
         if (m_disposing)
             return LogSubscriberInternal.DisposedSubscriber;
         var s = new LogSubscriberInternal(RecalculateRoutingTable);
         m_subscribers.Add(s.Reference);
         return s;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a <see cref="LogSubscriber"/>
 /// </summary>
 internal LogSubscriber(LogSubscriberInternal subscriber)
 {
     m_subscriber = subscriber;
 }