Exemplo n.º 1
0
        public void Dispose()
        {
            RequireWriteAccess();

// Make sure we're not double-disposing
#if ENABLE_UNITY_COLLECTIONS_CHECKS
#if UNITY_2018_3_OR_NEWER
            DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
#else
            DisposeSentinel.Dispose(m_Safety, ref m_DisposeSentinel);
#endif
#endif

            UnsafeUtility.Free(m_Buffer, m_AllocatorLabel);
            m_Buffer = null;
        }
Exemplo n.º 2
0
        public void Dispose()
        {
            if (m_Buffer == null)
            {
                return;
            }
            RequireWriteAccess();
#if ENABLE_UNITY_COLLECTIONS_CHECKS
#if UNITY_2018_3_OR_NEWER
            DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
#else
            DisposeSentinel.Dispose(m_Safety, ref m_DisposeSentinel);
#endif
#endif
            UnsafeUtility.Free(m_Buffer, m_AllocatorLabel);
            m_Buffer = null;
        }
        public void Dispose()
        {
            // When the NavMesh destroys itself it will disable read or write access.
            // Since it has been deallocated, we shouldn't deregister the query from it...
            // We need to extract removeQuery before disposing the handle,
            // because the atomic safety handle stores that state.
            var removeQuery = AtomicSafetyHandle.GetAllowReadOrWriteAccess(m_Safety);

            DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);

            if (removeQuery)
            {
                RemoveQuerySafety(m_NavMeshQuery, m_Safety);
            }
            Destroy(m_NavMeshQuery);
            m_NavMeshQuery = IntPtr.Zero;
        }
Exemplo n.º 4
0
        public void Dispose()
        {
            if (IsCreated)
            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                DisposeSentinel.Dispose(ref _safety, ref _disposeSentinel);
#endif

                this.CheckAllocator();
                UnsafeUtility.Free((void *)_ptr, _alloc);
                _ptr       = null;
                _isCreated = false;
            }
            else
            {
                throw new InvalidOperationException("Dispose() was called twise, or not initialized target.");
            }
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     this.elements.Dispose();
     this.elements = default;
     this.lookup.Dispose();
     this.lookup = default;
     this.nodes.Dispose();
     this.nodes     = default;
     this.isCreated = false;
     //UnsafeList.Destroy(this.elements);
     //this.elements = null;
     //UnsafeList.Destroy(this.lookup);
     //this.lookup = null;
     //UnsafeList.Destroy(this.nodes);
     //this.nodes = null;
     #if ENABLE_UNITY_COLLECTIONS_CHECKS
     DisposeSentinel.Dispose(ref this.safetyHandle, ref this.disposeSentinel);
     #endif
 }
Exemplo n.º 6
0
        public void Dispose()
        {
            if (m_Buffer == null)
            {
                throw new ObjectDisposedException("The NativeArray2D is already disposed.");
            }

            RequireWriteAccess();
            RequireValidAllocator(m_AllocatorLabel);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
#endif

            UnsafeUtility.Free(m_Buffer, m_AllocatorLabel);
            m_Buffer  = null;
            m_Length0 = 0;
            m_Length1 = 0;
        }
Exemplo n.º 7
0
        public void Dispose()
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
#endif
            if (m_ListData != null)
            {
                UnsafeUtility.Free(m_ListData->buffer, m_Allocator);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                m_ListData->buffer = (void *)0xDEADF00D;
#endif
                UnsafeUtility.Free(m_ListData, m_Allocator);
                m_ListData = null;
            }
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            else
            {
                throw new Exception("NativeList has yet to be allocated or has been dealocated!");
            }
#endif
        }
        public void Dispose()
        {
            if (m_Buffer == null)
            {
                throw new ObjectDisposedException("The NativeArray is already disposed.");
            }

            if (m_AllocatorLabel == Allocator.Invalid)
            {
                throw new InvalidOperationException("The NativeArray can not be Disposed because it was not allocated with a valid allocator.");
            }

            if (m_AllocatorLabel > Allocator.None)
            {
                DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
                UnsafeUtility.Free(m_Buffer, m_AllocatorLabel);
                m_AllocatorLabel = Allocator.Invalid;
            }

            m_Buffer = null;
        }
Exemplo n.º 9
0
        public void Dispose()
        {
            if (m_AllocatorLabel == Allocator.Invalid)
            {
                throw new InvalidOperationException("The NativeArray can not be Disposed because it was not allocated with a valid allocator.");
            }

            if (m_Buffer == null)
            {
                throw new InvalidOperationException("The NativeArray is already disposed.");
            }

            if (m_AllocatorLabel > Allocator.None)
            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
#endif
                UnsafeUtility.Free(m_Buffer, m_AllocatorLabel);
                m_AllocatorLabel = Allocator.Invalid;
            }

            m_Buffer = null;
            m_Length = 0;
        }
Exemplo n.º 10
0
        public void Dispose()
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel))
            {
                throw new InvalidOperationException("The NativeBucket can not be Disposed because it was not allocated with a valid allocator.");
            }
#if UNITY_2018_3_OR_NEWER
            DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
#else
            DisposeSentinel.Dispose(m_Safety, ref m_DisposeSentinel);
#endif
#endif
            for (int i = 0; i < JobsUtility.MaxJobThreadCount; ++i)
            {
                NativeBucketHeader *headerBlock = GetHeaderBlock(m_HeaderBlock, i);
                if (headerBlock->block != IntPtr.Zero)
                {
                    UnsafeUtility.Free((void *)headerBlock->block, m_AllocatorLabel);
                }
            }
            UnsafeUtility.Free(m_HeaderBlock, m_AllocatorLabel);
            m_HeaderBlock = null;
        }
Exemplo n.º 11
0
 public void Dispose()
 {
     DisposeSentinel.Dispose(this.m_Safety, ref this.m_DisposeSentinel);
     TransformAccessArray.DestroyTransformAccessArray(this.m_TransformArray);
     this.m_TransformArray = IntPtr.Zero;
 }
Exemplo n.º 12
0
        public void Dispose()
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel);
#endif
        }