Example #1
0
        // Token: 0x060007E2 RID: 2018 RVA: 0x0001CB2C File Offset: 0x0001AD2C
        private bool TryEnqueue(IList <T> items, out bool full)
        {
            full = false;
            ConcurrentBatchQueue <T> .Entity entity = this.m_Entity as ConcurrentBatchQueue <T> .Entity;
            T[] array  = entity.Array;
            int count  = entity.Count;
            int count2 = items.Count;
            int num    = count + count2;

            if (num > array.Length)
            {
                full = true;
                return(false);
            }
            if (entity != this.m_Entity)
            {
                return(false);
            }
            if (Interlocked.CompareExchange(ref entity.Count, num, count) != count)
            {
                return(false);
            }
            foreach (T t in items)
            {
                array[count++] = t;
            }
            return(true);
        }
Example #2
0
        // Token: 0x060007E4 RID: 2020 RVA: 0x0001CBD4 File Offset: 0x0001ADD4
        public bool TryDequeue(IList <T> outputItems)
        {
            ConcurrentBatchQueue <T> .Entity entity = this.m_Entity as ConcurrentBatchQueue <T> .Entity;
            if (entity.Count <= 0)
            {
                return(false);
            }
            if (Interlocked.CompareExchange(ref this.m_Entity, this.m_BackEntity, entity) != entity)
            {
                return(false);
            }
            Thread.SpinWait(1);
            int count = entity.Count;

            T[] array = entity.Array;
            int num   = 0;

            for (;;)
            {
                T arg = array[num];
                while (this.m_NullValidator(arg))
                {
                    Thread.SpinWait(1);
                    arg = array[num];
                }
                outputItems.Add(array[num]);
                array[num] = ConcurrentBatchQueue <T> .m_Null;
                if (entity.Count <= num + 1)
                {
                    break;
                }
                num++;
            }
            entity.Count      = 0;
            this.m_BackEntity = entity;
            return(true);
        }
Example #3
0
        // Token: 0x060007E0 RID: 2016 RVA: 0x0001CAA8 File Offset: 0x0001ACA8
        private bool TryEnqueue(T item, out bool full)
        {
            full = false;
            this.EnsureNotRebuild();
            ConcurrentBatchQueue <T> .Entity entity = this.m_Entity as ConcurrentBatchQueue <T> .Entity;
            T[] array = entity.Array;
            int count = entity.Count;

            if (count >= array.Length)
            {
                full = true;
                return(false);
            }
            if (entity != this.m_Entity)
            {
                return(false);
            }
            if (Interlocked.CompareExchange(ref entity.Count, count + 1, count) != count)
            {
                return(false);
            }
            array[count] = item;
            return(true);
        }