Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): allow parallel schedules #3485

Merged
merged 11 commits into from
May 2, 2022
Merged

fix(core): allow parallel schedules #3485

merged 11 commits into from
May 2, 2022

Conversation

nicojs
Copy link
Member

@nicojs nicojs commented Apr 29, 2022

Fix a race condition in the Pool class. Previously, parallel calls to .schedule() were not supported, this PR fixes it by adding some bookkeeping to keep track of work being done in other schedule calls.

Fixes #3473

@nicojs nicojs requested a review from simondel April 29, 2022 22:43
* Represents a work item: an input with a task and with a `result$` observable where the result (exactly one) will be streamed to.
*/
class WorkItem<TResource extends Resource, TIn, TOut> {
private readonly resultSubject = new Subject<TOut>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick: we could also use _result$ as a name to signal it's the private version of result$

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with regards to naming: if a Subject is not exposed as an Observable, I think the name Subject can be removed from the variable name all together (see class Pool)

packages/core/src/concurrent/pool.ts Outdated Show resolved Hide resolved
packages/core/src/concurrent/pool.ts Outdated Show resolved Hide resolved
@nicojs nicojs enabled auto-merge (squash) May 2, 2022 15:51
@nicojs
Copy link
Member Author

nicojs commented May 2, 2022

@simondel I've implemented some of the review comments and did even more improvements (made the resourcesSubject a local variable).

Let's talk tomorrow about the naming standard. I tried to be consistent:

  1. Subjects are postfixed with Subject
  2. Plain observables are postfixed with $

@nicojs nicojs merged commit bbbd514 into master May 2, 2022
@nicojs nicojs deleted the feat/pool-schedule branch May 2, 2022 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition in the MutationTestExecutor
2 participants