Beispiel #1
0
        public override void ChannelRead(IChannelHandlerContext ctx, object msg)
        {
            if (this.queue == null)
            {
                this.queue = Recycler.Take();
            }

            this.queue.TryEnqueue(msg);

            // We just received one message. Do we need to relay it regardless
            // of the auto reading configuration? The answer is yes if this
            // method was called as a result of a prior read() call.
            int minConsume = this.shouldConsume ? 1 : 0;

            this.shouldConsume = false;

            this.Dequeue(ctx, minConsume);
        }
Beispiel #2
0
        /**
         * Releases all messages and destroys the {@link Queue}.
         */
        void Destroy()
        {
            if (this.queue != null)
            {
                if (!this.queue.IsEmpty)
                {
                    Logger.Trace($"Non-empty queue: {this.queue}");

                    if (this.releaseMessages)
                    {
                        while (this.queue.TryDequeue(out object msg))
                        {
                            ReferenceCountUtil.SafeRelease(msg);
                        }
                    }
                }

                this.queue.Recycle();
                this.queue = null;
            }
        }