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

Improve waitgroups #41

Merged
merged 4 commits into from
Sep 8, 2023
Merged

Improve waitgroups #41

merged 4 commits into from
Sep 8, 2023

Conversation

konsumlamm
Copy link
Contributor

@konsumlamm konsumlamm commented Aug 29, 2023

  • fix some bugs:
    • assert delta >= 0 in enter by making the argument type Natural (Go also supports negative deltas, but those would require special handling)
    • leave does nothing if no tasks have entered (it could also throw an exception, like Go does)
    • only notify when runningTasks is 0 (not a bug fix, but an optimization)
    • use broadcast instead of signal in leave (this allows multiple threads to wait, there is a test for this)
  • add tests
  • improve documentation

What do you think about the behaviour of enter if delta < 0 and leave if runningTasks == 0?

@konsumlamm
Copy link
Contributor Author

#42 should fix the CI.

@Araq
Copy link
Member

Araq commented Aug 29, 2023

only notify when runningTasks is 0 (not a bug fix, but an optimization)

I wanted to do this optimization in Malebolgia but forgot. :-)

@Araq Araq closed this Aug 30, 2023
@Araq Araq reopened this Aug 30, 2023
@narimiran narimiran closed this Aug 30, 2023
@narimiran narimiran reopened this Aug 30, 2023
@narimiran
Copy link
Member

#42 should fix the CI.

I also did #43, so we don't test Nim 1.4 anymore.

@konsumlamm
Copy link
Contributor Author

@Araq what do you think?

@Araq Araq merged commit bcc2849 into nim-lang:master Sep 8, 2023
20 of 28 checks passed
@Araq
Copy link
Member

Araq commented Sep 8, 2023

It's great, thanks!

@konsumlamm konsumlamm deleted the waitgroups branch September 8, 2023 10:09
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.

3 participants