Ejemplo n.º 1
0
        public object Dequeue()
        {
            QueuedItem item = null;

            do
            {
                if (SocketServer.IsServerCounterEnabled)
                {
                    if (_perfStatsCollector != null)
                    {
                        _perfStatsCollector.SettNotificationQueueSizeStats(ConnectionManager.CallbackQueue.Count);
                    }
                }


                lock (this)
                {
                    if (_qeueues.Count != 0 && _count > 0)
                    {
                        if (_currentQueueIndex >= _qeueues.Count)
                        {
                            _currentQueueIndex = 0;
                        }

                        int startIndex = _currentQueueIndex;

                        for (; _currentQueueIndex < _qeueues.Count; _currentQueueIndex++)
                        {
                            item = DequeueInternal(_currentQueueIndex);
                            if (item != null)
                            {
                                break;
                            }
                        }

                        if (item == null)
                        {
                            for (int i = 0; i < startIndex; i++)
                            {
                                item = DequeueInternal(i);
                                if (item != null)
                                {
                                    _currentQueueIndex = i;
                                    break;
                                }
                            }
                        }
                    }

                    if (item == null)
                    {
                        Monitor.Wait(this);
                    }

                    _currentQueueIndex++;
                }
            } while (item == null && !_closed);

            return(item);
        }
Ejemplo n.º 2
0
        public object Dequeue()
        {
            QueuedItem item = null;

            do
            {
                lock (this)
                {
                    if (_qeueues.Count != 0 && _count > 0)
                    {
                        if (_currentQueueIndex >= _qeueues.Count)
                        {
                            _currentQueueIndex = 0;
                        }

                        int startIndex = _currentQueueIndex;

                        for (; _currentQueueIndex < _qeueues.Count; _currentQueueIndex++)
                        {
                            item = DequeueInternal(_currentQueueIndex);
                            if (item != null)
                            {
                                break;
                            }
                        }

                        if (item == null)
                        {
                            for (int i = 0; i < startIndex; i++)
                            {
                                item = DequeueInternal(i);
                                if (item != null)
                                {
                                    _currentQueueIndex = i;
                                    break;
                                }
                            }
                        }
                    }

                    if (item == null)
                    {
                        Monitor.Wait(this);
                    }

                    _currentQueueIndex++;
                }
            } while (item == null && !_closed);

            return(item);
        }
Ejemplo n.º 3
0
        private QueuedItem DequeueInternal(int queueIndex)
        {
            QueuedItem item       = null;
            QueuedItem queuedItem = new Alachisoft.NCache.SocketServer.QueuedItem();

            try
            {
                IQueue innerQueue = _qeueues[queueIndex].Queue;
                queuedItem.RegisteredClientId = _qeueues[queueIndex].RegisteredClientId;

                if (innerQueue.Count > 0)
                {
                    item            = (QueuedItem)innerQueue.Dequeue(); // inner queue also return an queued item object
                    queuedItem.Item = item.Item;
                    _count         -= item.Count;
                }
            }
            catch (Exception)
            { }

            return(queuedItem);
        }
Ejemplo n.º 4
0
        public object Dequeue()
        {
            object     eventItem;
            QueuedItem item;

            Alachisoft.NCache.Common.Protobuf.Response          response  = null;
            Alachisoft.NCache.Common.Protobuf.BulkEventResponse bulkEvent = new Common.Protobuf.BulkEventResponse();

            lock (this)
            {
                item = new QueuedItem();
                for (int i = 1; i <= _eventBulkCount && _queue.Count > 0; i++)
                {
                    eventItem = null;
                    {
                        eventItem  = _queue.Dequeue();
                        item.Count = i;
                    }

                    if (eventItem == null)
                    {
                        break;
                    }

                    bulkEvent.eventList.Add((Alachisoft.NCache.Common.Protobuf.BulkEventItemResponse)eventItem);
                }

                if (bulkEvent.eventList.Count > 0)
                {
                    response = new Common.Protobuf.Response();
                    response.bulkEventResponse = bulkEvent;
                    response.responseType      = Common.Protobuf.Response.Type.BULK_EVENT;
                }

                item.Item = (object)response;
                return(item);
            }
        }
Ejemplo n.º 5
0
        public object Dequeue()
        {
            object eventItem;
            QueuedItem item;
            
            Alachisoft.NCache.Common.Protobuf.Response response = null;
            Alachisoft.NCache.Common.Protobuf.BulkEventResponse bulkEvent = new Common.Protobuf.BulkEventResponse();

            lock (this)
            {
                item = new QueuedItem();
                for (int i = 1; i <= _eventBulkCount && _queue.Count>0 ; i++)
                {
                    eventItem = null;
                    {
                        eventItem = _queue.Dequeue();
                        item.Count = i;                         
                    }

                    if (eventItem == null)
                        break;

                    bulkEvent.eventList.Add((Alachisoft.NCache.Common.Protobuf.BulkEventItemResponse)eventItem);
                }

                if (bulkEvent.eventList.Count > 0)
                {
                    response = new Common.Protobuf.Response();
                    response.bulkEventResponse = bulkEvent;
                    response.responseType = Common.Protobuf.Response.Type.BULK_EVENT;
                }

                item.Item = (object)response;
                return item;
            }
        }