示例#1
0
        public ITask Parallelize(ICollection <ITask> tasks)
        {
            string            name         = string.Format("parallelization of {0} tasks", tasks.Count);
            IEnumerableAction serialAction = EnumerableAction.Create(() => StartParallelTasks(tasks), tasks.Count, name);

            return(this.FromEnumerableAction(serialAction));
        }
示例#2
0
        public ITask <T> FromEnumerableAction <T>(IEnumerableAction <T> action)
            where T : class
        {
            CoroutineTask <T> task = new CoroutineTask <T>(this, action);

            task.ExceptionHandling = this.exceptionHandling;

            return(task);
        }
示例#3
0
        public ITask Enqueue(IEnumerableAction enumerableAction)
        {
            QueueTask task = new QueueTask(this, enumerableAction);

            lock (_lock)
            {
                _tasks.Enqueue(task);
            }

            return(task);
        }
示例#4
0
        public ITask Parallelize(System.Func <bool> poller, float timeout = -1f, string name = "")
        {
            IEnumerableAction action = EnumerableAction.Create(() => WaitOnCondition(poller), 1, name);
            QueueTask         task   = new QueueTask(this, action)
            {
                RequestedTimeout = timeout
            };

            lock (_lock)
            {
                _tasks.Enqueue(task);
            }

            return(task);
        }
        static IEnumerator _Concat(IEnumerableAction action1, IEnumerableAction action2)
        {
            IEnumerator enumerator = action1.Run();

            while (enumerator.MoveNext())
            {
                yield return(enumerator.Current);
            }

            enumerator = action2.Run();
            while (enumerator.MoveNext())
            {
                yield return(enumerator.Current);
            }
        }
示例#6
0
 public QueueTask(TaskFactory taskFactory, IEnumerableAction serialAction)
     : base(taskFactory, serialAction)
 {
 }
 public static IEnumerableAction Concat(IEnumerableAction action1, IEnumerableAction action2)
 {
     return(Create(() => _Concat(action1, action2)));
 }
 static EnumerableAction()
 {
     s_nullAction = new Action(NullAction, 1, "NullAction");
 }
 public Coroutine StartCoroutine(IEnumerableAction enumerableAction)
 {
     return(StartCoroutine(() => enumerableAction.Run()));
 }
示例#10
0
 public CoroutineTask(ICoroutineFactory coroutineFactory, IEnumerableAction serialAction)
     : base(coroutineFactory, serialAction)
 {
 }