Esempio n. 1
0
 // Update is called once per frame
 public void OnUpdate()
 {
     while (_ready[_currentReadyIndex].Count > 0)
     {
         int           nextTaskId = _ready[_currentReadyIndex].Dequeue();
         CoroutineTask task       = null;
         if (_taskMap.ContainsKey(nextTaskId))
         {
             task = _taskMap[nextTaskId];
         }
         else
         {
             continue;
         }
         try{
             SystemTask result = task.Run();
             if (result != null)
             {
                 result.task = task;
                 result.Handle();
                 continue;
             }
         }
         catch (StopIteration e)
         {
             Exit(task);
             continue;
         }
         Schedule(task.taskId);
     }
     _currentReadyIndex = 1 - _currentReadyIndex;
 }
Esempio n. 2
0
        public void Callback(int taskId, object result)
        {
            CoroutineTask task = _taskMap[taskId];

            task.sendval = result;
            Schedule(task.taskId);
        }
Esempio n. 3
0
        public int New(IEnumerator target)
        {
            CoroutineTask newTask = new CoroutineTask(target);

            _taskMap [newTask.taskId] = newTask;
            Schedule(newTask.taskId);
            return(newTask.taskId);
        }
Esempio n. 4
0
        public override void Handle()
        {
            CoroutineTask task = Singleton <CoroutineDecorator> .Instance.getCoroutineTask(_taskId);

            if (task != null)
            {
                task.Stop();
            }
            Singleton <CoroutineDecorator> .Instance.Schedule(task.taskId);
        }
Esempio n. 5
0
 public void Exit(CoroutineTask task)
 {
     _taskMap.Remove(task.taskId);
     if (_exitWaiting.ContainsKey(task.taskId))
     {
         List <int> pendingTasks = _exitWaiting [task.taskId];
         _exitWaiting.Remove(task.taskId);
         foreach (int ataskid in pendingTasks)
         {
             CoroutineTask atask = _taskMap[ataskid];
             Schedule(atask.taskId);
         }
     }
 }
Esempio n. 6
0
 public bool WaitForExit(CoroutineTask task, int waitId)
 {
     if (_taskMap.ContainsKey(waitId))
     {
         if (!_exitWaiting.ContainsKey(waitId))
         {
             _exitWaiting[waitId] = new List <int>();
         }
         _exitWaiting[waitId].Add(task.taskId);
         return(true);
     }
     else
     {
         return(false);
     }
 }