thefrontside / bigtest

Ensure your React/Vue/Ember/anything app works perfectly across browsers.
https://frontside.com/bigtest
99 stars 14 forks source link

Use task group for collecting tasks with the same lifetime #1068

Closed cowboyd closed 2 years ago

cowboyd commented 2 years ago

Motivation

Instead of using an option 'blockParent'. We can explicitly spawn different tasks into collections of groups that can be waited upon individually. This not only makes which group a task is part of explicit, but it allows flexibility in how you consume the blocking tasks.

This is fairly common in other structured concurrency frameworks like Swift or ember-concurrency, and can be expanded upon to add other aspects like "how many concurrent things can be going at the same time" or "what do we do when the max concurrency is attained... do we drop incoming operations? do we respond with a "503 operation"? do we cancel the currently running things? do we enqueue the new operations? How many do we enqueue?"

So this is an experiment in what that might look like.

changeset-bot[bot] commented 2 years ago

🦋 Changeset detected

Latest commit: b4acb1f7b903e76786654b58d4cc99a6bda80918

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------- | ----- | | @bigtest/server | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

dagda1 commented 2 years ago

Looks like a good idea

Should this not be part of effection itself?

At the moment, I don't see any max task restriction, is this still to be added?

cowboyd commented 2 years ago

Looks like a good idea

Should this not be part of effection itself?

At the moment, I don't see any max task restriction, is this still to be added?

Yes, this is more of a proving ground for the idea, and then when we're happy with it we can add it to Effection proper. I was thinking something like

function* run() {
  let group = yield createTaskGroup('socket handlers', {
    maxConcurrency: 200,
    drop: 'latest'
  });
}