unsafe public void Enqueue(T entry) { #if ENABLE_UNITY_COLLECTIONS_CHECKS AtomicSafetyHandle.CheckWriteAndThrow(m_Safety); #endif byte *writeBlock = NativeQueueData.AllocateWriteBlockMT <T>(m_Buffer, m_QueuePool, 0); UnsafeUtility.WriteArrayElement(writeBlock + UnsafeUtility.SizeOf <NativeQueueBlockHeader>(), ((NativeQueueBlockHeader *)writeBlock)->itemsInBlock, entry); ++((NativeQueueBlockHeader *)writeBlock)->itemsInBlock; }
public unsafe NativeQueue(Allocator label) { m_QueuePool = NativeQueueBlockPool.QueueBlockPool; #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsBlittable <T>()) { throw new ArgumentException(string.Format("{0} used in NativeQueue<{0}> must be blittable", typeof(T))); } #endif m_AllocatorLabel = label; NativeQueueData.AllocateQueue <T>(label, out m_Buffer); #if ENABLE_UNITY_COLLECTIONS_CHECKS DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, 0, label); #endif }