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)); }
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); }
public ITask Enqueue(IEnumerableAction enumerableAction) { QueueTask task = new QueueTask(this, enumerableAction); lock (_lock) { _tasks.Enqueue(task); } return(task); }
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); } }
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())); }
public CoroutineTask(ICoroutineFactory coroutineFactory, IEnumerableAction serialAction) : base(coroutineFactory, serialAction) { }