Exemple #1
0
        public void Dispose()
        {
            for (var i = 0; i < Pages.Count; i++)
            {
                BufferSource.Return(Pages[i]);
            }

            Pages.Clear();
        }
Exemple #2
0
        public void Dispose()
        {
            var pages = Pages;
            var count = pages.Count;

            for (var i = 0; i < count; i++)
            {
                BufferSource.Return(pages[i]);
            }

            pages.Clear();
        }
Exemple #3
0
        private char[] NewPage()
        {
            char[] page = null;
            try
            {
                page = BufferSource.Rent(PageSize);
                Pages.Add(page);
            }
            catch when(page != null)
            {
                BufferSource.Return(page);
                throw;
            }

            return(page);
        }
Exemple #4
0
        /// <summary>
        /// Return all but one of the pages to the <see cref="ICharBufferSource"/>.
        /// This way if someone writes a large chunk of content, we can return those buffers and avoid holding them
        /// for extended durations.
        /// </summary>
        public void Clear()
        {
            for (var i = Pages.Count - 1; i > 0; i--)
            {
                var page = Pages[i];

                try
                {
                    Pages.RemoveAt(i);
                }
                finally
                {
                    BufferSource.Return(page);
                }
            }

            _charIndex  = 0;
            CurrentPage = Pages.Count > 0 ? Pages[0] : null;
        }