Exemple #1
0
        public RoutineStats GetStats()
        {
            RoutineStats stats = new RoutineStats();

            stats.Handle = m_Handle;
            stats.Host   = ReferenceEquals(m_Host, Manager) ? null : m_Host;

            if (m_Disposing || (!m_HostedByManager && !m_Host))
            {
                stats.State = RoutineState.Disposing;
            }
            else if (IsPaused())
            {
                stats.State = RoutineState.Paused;
            }
            else if (m_WaitTime > 0)
            {
                stats.State = RoutineState.WaitTime;
            }
            else if (m_UnityWait != null)
            {
                stats.State = RoutineState.WaitUnity;
            }
            else
            {
                stats.State = RoutineState.Running;
            }

            stats.TimeScale = m_TimeScale;
            stats.Name      = Name;
            stats.Priority  = Priority;

            if (m_StackPosition >= 0)
            {
                IEnumerator current = m_Stack[m_StackPosition];
                stats.Function = CleanIteratorName(current);

                // HACK - to visualize combine iterators properly
                ParallelFibers combine = current as ParallelFibers;
                if (combine != null)
                {
                    stats.Nested = combine.GetStats();
                }
            }
            else
            {
                stats.Function = null;
            }

            stats.StackDepth = m_StackPosition + 1;

            return(stats);
        }
Exemple #2
0
 /// <summary>
 /// Indicates that the Fiber is owned by the given ParallelFiber.
 /// </summary>
 public void SetParallelOwner(ParallelFibers inParallel)
 {
     m_Parallel = inParallel;
 }
Exemple #3
0
 /// <summary>
 /// Clears the Fiber's ParallelFiber owner.
 /// </summary>
 public void ClearParallelOwner()
 {
     m_Parallel = null;
 }
Exemple #4
0
        /// <summary>
        /// Cleans up the Fiber.
        /// </summary>
        public void Dispose()
        {
            if ((uint)m_Handle == 0)
            {
                return;
            }

            if (m_UnityWait != null)
            {
                Manager.Host.StopCoroutine(m_UnityWait);
                m_UnityWait = null;
            }

            bool bKilled  = m_StackPosition >= 0;
            bool bChained = m_Chained;

            ClearStack();

            m_Handle       = Routine.Null;
            m_Host         = null;
            m_HostIdentity = null;

            // If this is chained and we have a parallel
            if (bChained && m_Parallel != null)
            {
                m_Parallel.RemoveFiber(this);
            }

            m_Chained = m_Disposing = m_HasIdentity
                                          = m_Paused = m_IgnoreObjectTimescale = m_HostedByManager
                                                                                     = m_IgnoreObjectActive = m_Executing = false;

            m_WaitTime = 0;
            m_Name     = null;
            Priority   = 0;

            m_Parallel  = null;
            m_RootFiber = null;

            m_TimeScale       = 1.0f;
            m_YieldFrameDelay = 0;

            if (m_YieldPhase != YieldPhase.None)
            {
                Manager.Fibers.RemoveFiberFromYieldList(this, m_YieldPhase);
                m_YieldPhase = YieldPhase.None;
            }

            if (!bChained)
            {
                Manager.Fibers.RemoveFiberFromUpdateList(this, m_UpdatePhase);
            }
            Manager.RecycleFiber(this, bChained);

            m_UpdatePhase      = Manager.DefaultPhase;
            m_OnException      = null;
            m_HandleExceptions = false;

            if (bKilled)
            {
                m_OnComplete = null;
                Action onStop = m_OnStop;
                m_OnStop = null;
                if (onStop != null)
                {
                    onStop();
                }
            }
            else
            {
                m_OnStop = null;
                Action onComplete = m_OnComplete;
                m_OnComplete = null;
                if (onComplete != null)
                {
                    onComplete();
                }
            }
        }