Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public ITask Enqueue(IEnumerableAction enumerableAction)
        {
            QueueTask task = new QueueTask(this, enumerableAction);

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

            return(task);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 public QueueTask(TaskFactory taskFactory, IEnumerableAction serialAction)
     : base(taskFactory, serialAction)
 {
 }
Exemplo n.º 7
0
 public static IEnumerableAction Concat(IEnumerableAction action1, IEnumerableAction action2)
 {
     return(Create(() => _Concat(action1, action2)));
 }
Exemplo n.º 8
0
 static EnumerableAction()
 {
     s_nullAction = new Action(NullAction, 1, "NullAction");
 }
Exemplo n.º 9
0
 public Coroutine StartCoroutine(IEnumerableAction enumerableAction)
 {
     return(StartCoroutine(() => enumerableAction.Run()));
 }
Exemplo n.º 10
0
 public CoroutineTask(ICoroutineFactory coroutineFactory, IEnumerableAction serialAction)
     : base(coroutineFactory, serialAction)
 {
 }