In the following example:
var group = new TaskGroup();
group.setConfig({concurrency: 1});
group.addTask(function () {
console.log('Running first task outside of group.');
});
// Add a sub-group to our exiting group
group.addGroup(function(){
// Tell this sub-group to execute in parallel (all at once) by setting its
// concurrency to unlimited by default the concurrency for all groups is set
// to 1 which means that they execute in serial fashion (one after the other,
// instead of all at once)
this.setConfig({concurrency: 0});
// Add an asynchronous task that gives its result to the completion callback
this.addTask(function(complete){
setTimeout(function(){
console.log('Running asynchronous task in group.')
},500);
});
// Add a synchronous task that returns its result
this.addTask(function(){
console.log("Running synchronous task in group.")
});
});
group.addTask(function () {
console.log('Running second task outside of group.');
});
group.run()
I get the following result:
Running first task outside of group.
Running synchronous task in group.
Running asynchronous task in group.
The second task outside of the group is not fired. If I configure the concurrency of the task group to 0 instead of 1, it does fire as expected.
In the following example:
I get the following result:
The second task outside of the group is not fired. If I configure the concurrency of the task group to 0 instead of 1, it does fire as expected.