Beispiel #1
0
 private IBatchQueue <ArraySegment <byte> > GetSendingQueue()
 {
     if (m_SendingQueue != null)
     {
         return(m_SendingQueue);
     }
     lock (this)
     {
         if (m_SendingQueue != null)
         {
             return(m_SendingQueue);
         }
         m_SendingQueue = new ConcurrentBatchQueue <ArraySegment <byte> >(Math.Max(base.SendingQueueSize, 1024), (ArraySegment <byte> t) => t.Array == null || t.Count == 0);
         return(m_SendingQueue);
     }
 }
Beispiel #2
0
        private IBatchQueue <ArraySegment <byte> > GetSendingQueue()
        {
            if (m_SendingQueue != null)
            {
                return(m_SendingQueue);
            }

            lock (this)
            {
                if (m_SendingQueue != null)
                {
                    return(m_SendingQueue);
                }

                //Sending queue size must be greater than 3
                m_SendingQueue = new ConcurrentBatchQueue <ArraySegment <byte> >(Math.Max(SendingQueueSize, 3), (t) => t.Array == null);
                return(m_SendingQueue);
            }
        }
Beispiel #3
0
        public BatchTimer(IBatchQueue <T> queue, IBatchNotifier <T> notifier, IServiceProvider services, IOptions <ApogeeOptions> options)
        {
            _queue          = queue;
            _services       = services;
            _interval       = options.Value.FlushInterval.TotalMilliseconds;
            _timer          = new Timer(_interval);
            _timer.Elapsed += Elapsed;

            if (options.Value.MaximumQueueCountBeforeAutoFlush.HasValue)
            {
                _maximumQueueCountBeforeAutoFlush = options.Value.MaximumQueueCountBeforeAutoFlush.Value;
                notifier.Notified += FlushIfOverCount;
            }
            else
            {
                notifier.Notified += ResetTimer;
            }
            notifier.Flushed += Notifier_Flushed;
        }
Beispiel #4
0
 private IBatchQueue <ArraySegment <byte> > GetSendingQueue()
 {
     if (this.m_SendingQueue != null)
     {
         return(this.m_SendingQueue);
     }
     lock (this) {
         if (this.m_SendingQueue != null)
         {
             return(this.m_SendingQueue);
         }
         this.m_SendingQueue = (IBatchQueue <ArraySegment <byte> >) new ConcurrentBatchQueue <ArraySegment <byte> >(
             Math.Max(this.SendingQueueSize, 1024), (Func <ArraySegment <byte>, bool>)(t => {
             if (t.Array != null)
             {
                 return(t.Count == 0);
             }
             return(true);
         }));
         return(this.m_SendingQueue);
     }
 }
        private IBatchQueue<ArraySegment<byte>> GetSendingQueue()
        {
            if (m_SendingQueue != null)
                return m_SendingQueue;

            lock (this)
            {
                if (m_SendingQueue != null)
                    return m_SendingQueue;

                //Sending queue size must be greater than 3
                m_SendingQueue = new ConcurrentBatchQueue<ArraySegment<byte>>(Math.Max(SendingQueueSize, 1024), (t) => t.Array == null || t.Count == 0);
                return m_SendingQueue;
            }
        }
Beispiel #6
0
 public BatchService(IApogeeFlusher flusher, IBatchQueue <T> queue, IBatchNotifier <T> batchNotifier)
 {
     flusher.Register(Flush);
     _queue         = queue;
     _batchNotifier = batchNotifier;
 }