Beispiel #1
0
 public unsafe T this[int index]
 {
     get
     {
         AtomicSafetyHandleVersionMask *ptr = (AtomicSafetyHandleVersionMask *)((void *)this.m_Safety.versionNode);
         if ((this.m_Safety.version & AtomicSafetyHandleVersionMask.Read) == (AtomicSafetyHandleVersionMask)0 && this.m_Safety.version != (*ptr & AtomicSafetyHandleVersionMask.ReadInv))
         {
             AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(this.m_Safety);
         }
         if (index < this.m_MinIndex || index > this.m_MaxIndex)
         {
             this.FailOutOfRangeError(index);
         }
         return(UnsafeUtility.ReadArrayElement <T>(this.m_Buffer, index * this.m_Stride));
     }
     set
     {
         AtomicSafetyHandleVersionMask *ptr = (AtomicSafetyHandleVersionMask *)((void *)this.m_Safety.versionNode);
         if ((this.m_Safety.version & AtomicSafetyHandleVersionMask.Write) == (AtomicSafetyHandleVersionMask)0 && this.m_Safety.version != (*ptr & AtomicSafetyHandleVersionMask.WriteInv))
         {
             AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut(this.m_Safety);
         }
         if (index < this.m_MinIndex || index > this.m_MaxIndex)
         {
             this.FailOutOfRangeError(index);
         }
         UnsafeUtility.WriteArrayElement <T>(this.m_Buffer, index * this.m_Stride, value);
     }
 }
        void CheckElementReadAccess(int index)
        {
            if (index < m_MinIndex || index > m_MaxIndex)
            {
                FailOutOfRangeError(index);
            }

            var versionPtr = (int *)m_Safety.versionNode;

            if (m_Safety.version != ((*versionPtr) & AtomicSafetyHandle.ReadCheck))
            {
                AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(m_Safety);
            }
        }
        void CheckElementReadAccess(int index)
        {
            if (index < m_MinIndex || index > m_MaxIndex)
            {
                FailOutOfRangeError(index);
            }

            var versionPtr = (AtomicSafetyHandleVersionMask *)m_Safety.versionNode;

            if ((m_Safety.version & AtomicSafetyHandleVersionMask.Read) == 0 && m_Safety.version != ((*versionPtr) & AtomicSafetyHandleVersionMask.WriteInv))
            {
                AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(m_Safety);
            }
        }
Beispiel #4
0
            void CheckElementReadAccess(int index)
            {
                if (index < 0 || index >= m_Length)
                {
                    throw new IndexOutOfRangeException($"Index {index} is out of range (must be between 0 and {m_Length-1}).");
                }

                var versionPtr = (int *)m_Safety.versionNode;

                if (m_Safety.version != ((*versionPtr) & AtomicSafetyHandle.ReadCheck))
                {
                    AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(m_Safety);
                }
            }
        private unsafe void CheckReadIndex(int index)
        {
            #if COLLECTIONS_CHECKS
            if (index < this.m_MinIndex || index > this.m_MaxIndex)
            {
                this.FailOutOfRangeError(index);
            }

            if (this.m_Safety.version == (*(int *)(void *)this.m_Safety.versionNode & -7))
            {
                return;
            }

            AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(this.m_Safety);
            #endif
        }
Beispiel #6
0
        private unsafe void CheckReadIndex(int index)
        {
            bool flag = index <this.m_MinIndex || index> this.m_MaxIndex;

            if (flag)
            {
                this.FailOutOfRangeError(index);
            }
            int *ptr   = (int *)((void *)this.m_Safety.versionNode);
            bool flag2 = this.m_Safety.version != (*ptr & -7);

            if (flag2)
            {
                AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(this.m_Safety);
            }
        }
Beispiel #7
0
            private unsafe void CheckElementReadAccess(int index)
            {
                bool flag = index < 0 || index >= this.m_Length;

                if (flag)
                {
                    throw new IndexOutOfRangeException(string.Format("Index {0} is out of range (must be between 0 and {1}).", index, this.m_Length - 1));
                }
                int *ptr   = (int *)((void *)this.m_Safety.versionNode);
                bool flag2 = this.m_Safety.version != (*ptr & -7);

                if (flag2)
                {
                    AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(this.m_Safety);
                }
            }
Beispiel #8
0
 public unsafe T this[int index]
 {
     get
     {
         if (this.m_Buffer == IntPtr.Zero)
         {
             throw new InvalidOperationException("NativeSlice not properly initialized");
         }
         AtomicSafetyHandleVersionMask *ptr = (AtomicSafetyHandleVersionMask *)((void *)this.m_Safety.versionNode);
         if ((this.m_Safety.version & AtomicSafetyHandleVersionMask.Read) == (AtomicSafetyHandleVersionMask)0 && this.m_Safety.version != (*ptr & AtomicSafetyHandleVersionMask.WriteInv))
         {
             AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut(this.m_Safety);
         }
         if (index < this.m_MinIndex || index > this.m_MaxIndex)
         {
             this.FailOutOfRangeError(index);
         }
         return(UnsafeUtility.ReadArrayElementWithStride <T>(this.m_Buffer, index, this.m_Stride));
     }
     set
     {
         if (this.m_Buffer == IntPtr.Zero)
         {
             throw new InvalidOperationException("NativeSlice not properly initialized");
         }
         AtomicSafetyHandleVersionMask *ptr = (AtomicSafetyHandleVersionMask *)((void *)this.m_Safety.versionNode);
         if ((this.m_Safety.version & AtomicSafetyHandleVersionMask.Write) == (AtomicSafetyHandleVersionMask)0 && this.m_Safety.version != (*ptr & AtomicSafetyHandleVersionMask.ReadInv))
         {
             AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut(this.m_Safety);
         }
         if (index < this.m_MinIndex || index > this.m_MaxIndex)
         {
             this.FailOutOfRangeError(index);
         }
         UnsafeUtility.WriteArrayElementWithStride <T>(this.m_Buffer, index, this.m_Stride, value);
     }
 }