added Taskparallel class that executest tasks in parallel

This commit is contained in:
2016-05-15 15:28:38 +02:00
parent b1eeb3563e
commit 8944ae2462
18 changed files with 113 additions and 49 deletions

View File

@@ -0,0 +1,29 @@
/// <reference path="./typings/main.d.ts" />
import * as plugins from "./taskbuffer.plugins"
import * as helpers from "./taskbuffer.classes.helpers"
import {Task} from "./taskbuffer.classes.task"
export class Taskparallel extends Task {
taskArray:Task[];
constructor(optionsArg:{
taskArray:Task[]
}){
let options = plugins.lodash.assign(
optionsArg,
{
taskFunction:() => {
let done = plugins.Q.defer();
let promiseArray; // stores promises of all tasks, since they run in parallel
this.taskArray.forEach(function(taskArg:Task){
promiseArray.push(taskArg.trigger());
})
plugins.Q.all(promiseArray)
.then(done.resolve);
return done.promise;
}
}
)
super(options);
}
}