static void SequentialTasksFlushing(
     ThreadSafeQueue <IPausableTask> newTaskRoutines,
     FasterList <IPausableTask> coroutines,
     UnityCoroutineRunner.FlushingOperation flushingOperation)
 {
     if (newTaskRoutines.Count > 0 && coroutines.Count == 0)
     {
         newTaskRoutines.DequeueInto(coroutines, 1);
     }
 }
 static void StaggeredTasksFlushing(
     ThreadSafeQueue <IPausableTask> newTaskRoutines,
     FasterList <IPausableTask> coroutines,
     UnityCoroutineRunner.FlushingOperation flushingOperation)
 {
     if (newTaskRoutines.Count > 0)
     {
         newTaskRoutines.DequeueInto(coroutines, ((FlushingOperationStaggered)flushingOperation).maxTasksPerFrame);
     }
 }
Exemple #3
0
        public StaggeredMonoRunner(string name, int maxTasksPerIteration, bool mustSurvive = false) : base(name)
        {
            _flushingOperation = new UnityCoroutineRunner.FlushingOperation();

            UnityCoroutineRunner.InitializeGameObject(name, ref _go, mustSurvive);

            var runnerBehaviour = _go.AddComponent <RunnerBehaviourUpdate>();
            var info            = new StaggeredRunningInfo(maxTasksPerIteration)
            {
                runnerName = name
            };

            runnerBehaviour.StartUpdateCoroutine(new UnityCoroutineRunner.Process <StaggeredRunningInfo>
                                                     (_newTaskRoutines, _coroutines, _flushingOperation, info));
        }
        public TimeSlicedMonoRunner(string name, float maxMilliseconds, bool mustSurvive = false) : base(name)
        {
            _flushingOperation = new UnityCoroutineRunner.FlushingOperation();

            UnityCoroutineRunner.InitializeGameObject(name, ref _go, mustSurvive);

            var runnerBehaviour = _go.AddComponent <RunnerBehaviourUpdate>();

            _info = new TimeSlicedRunningInfo(maxMilliseconds, _coroutines)
            {
                runnerName = name
            };

            runnerBehaviour.StartUpdateCoroutine(new UnityCoroutineRunner.Process <TimeSlicedRunningInfo>
                                                     (_newTaskRoutines, _coroutines, _flushingOperation, _info));
        }
        public TimeBoundMonoRunner(string name, float maxMilliseconds, bool mustSurvive = false)
        {
            _flushingOperation = new UnityCoroutineRunner.FlushingOperation();

            UnityCoroutineRunner.InitializeGameObject(name, ref _go, mustSurvive);

            var runnerBehaviour = _go.AddComponent <RunnerBehaviourUpdate>();
            var runnerBehaviourForUnityCoroutine = _go.AddComponent <RunnerBehaviour>();
            var info = new TimeBoundRunningInfo(maxMilliseconds)
            {
                runnerName = name
            };

            runnerBehaviour.StartUpdateCoroutine(new UnityCoroutineRunner.Process
                                                     (_newTaskRoutines, _coroutines, _flushingOperation, info,
                                                     UnityCoroutineRunner.StandardTasksFlushing,
                                                     runnerBehaviourForUnityCoroutine, StartCoroutine));
        }