/// <summary>
        /// Try to remove an element from the queue.
        /// </summary>
        /// <param name="result">
        /// If there's a element available, this parameter will be updated to
        /// that element.
        /// </param>
        /// <returns>Whether the dequeueing operation succeeded.</returns>
        public bool TryDequeue(out T *result)
        {
            result = null;
            AtomicNode *root = AcquireRoot();

            var first    = (AtomicNode *)root->Next;
            var dequeued = (first != null);

            if (dequeued)
            {
                result     = (T *)first->Payload;
                root->Next = first->Next;
                // if the first node was also the last node, we need to mark the last pointer as well
                if (root->Payload == (long)first)
                {
                    root->Payload = 0;
                }
            }

            ReleaseRoot(root);
            if (dequeued)
            {
                FreeList.Release(first);
            }
            return(dequeued);
        }
示例#2
0
    void ClearIncrementalConversion(GameObject gameObject)
    {
        int index;

        if (!m_GameObjectToEntity.TryGetValue(gameObject.GetInstanceID(), out index))
        {
            throw new ArgumentException($"GameObject {gameObject} has changed but is not known to the incremental conversion.");
        }

        var e = m_Entities.Data[index];

        if (m_DstManager.HasComponent <Prefab>(e))
        {
            throw new ArgumentException("An Entity with a Prefab tag cannot be updated during incremental conversion");
        }

        m_DstManager.SetArchetype(e, GetCleanIncrementalArchetype(e));

        var additionalIndex = m_Entities.Next[index];

        while (additionalIndex != -1)
        {
            e = m_Entities.Data[additionalIndex];
            if (m_DstManager.HasComponent <LinkedEntityGroup>(e))
            {
                throw new ArgumentException("An Entity with a LinkedEntityGroup cannot be destroyed during incremental conversion");
            }
            if (m_DstManager.HasComponent <Prefab>(e))
            {
                throw new ArgumentException("An Entity with a Prefab tag cannot be updated during incremental conversion");
            }

            m_DstManager.DestroyEntity(e);

            int releaseIndex = additionalIndex;
            additionalIndex = m_Entities.Next[additionalIndex];
            m_Entities.Release(releaseIndex);
        }

        m_Entities.Next[index] = -1;
    }