コード例 #1
0
        /// <summary>
        /// Constructs a new queue with type of memory allocation.
        /// </summary>
        /// <param name="allocator">A member of the
        /// [Unity.Collections.Allocator](https://docs.unity3d.com/ScriptReference/Unity.Collections.Allocator.html) enumeration.</param>
        public NativeQueue(Allocator allocator)
        {
            CollectionHelper.CheckIsUnmanaged <T>();

            m_QueuePool      = NativeQueueBlockPool.QueueBlockPool;
            m_AllocatorLabel = allocator;

            NativeQueueData.AllocateQueue <T>(allocator, out m_Buffer);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, 0, allocator);
#endif
        }
コード例 #2
0
        /// <summary>
        /// Constructs a new queue with type of memory allocation.
        /// </summary>
        /// <param name="allocator">A member of the
        /// [Unity.Collections.Allocator](https://docs.unity3d.com/ScriptReference/Unity.Collections.Allocator.html) enumeration.</param>
        public NativeQueue(Allocator allocator)
        {
            CollectionHelper.CheckIsUnmanaged <T>();

            m_QueuePool      = NativeQueueBlockPool.QueueBlockPool;
            m_AllocatorLabel = allocator;

            NativeQueueData.AllocateQueue <T>(allocator, out m_Buffer);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, 0, allocator);

            if (s_staticSafetyId.Data == 0)
            {
                CreateStaticSafetyId();
            }
            AtomicSafetyHandle.SetStaticSafetyId(ref m_Safety, s_staticSafetyId.Data);
#endif
        }
コード例 #3
0
 public void Dispose()
 {
     NativeQueueData.DeallocateQueue(m_Buffer, m_QueuePool, m_AllocatorLabel);
 }