Skip to content

Task doesn't fire when changing concurrencey config between taskgroups and sub taskgroups. #6

@crito

Description

@crito

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions