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

Remove EventLoopError::AlreadyRunning #3425

Merged
merged 2 commits into from
Jan 29, 2024
Merged

Conversation

madsmtm
Copy link
Member

@madsmtm madsmtm commented Jan 25, 2024

This is already prevented by the type-system, and as such it doesn't make sense to have an error case for this.

This was added by @rib in #2767, maybe you can shed some light on if this was an oversight added out of an abundance of caution, or if you think my reasoning is wrong here, and the error actually can happen?

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users

This is already prevented by the type-system, and as such it doesn't make sense to have an error case for this.
Copy link
Member

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

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

From a quick view this makes sense. The EventLoop cannot be mutably borrowed more than once, and there's no way to Copy/Clone one to get multiple mutable references either.

@kchibisov kchibisov merged commit f526a47 into master Jan 29, 2024
51 checks passed
@kchibisov kchibisov deleted the remove-already-running branch January 29, 2024 18:06
@rib
Copy link
Contributor

rib commented Jan 29, 2024

Bit late but I think those checks relate to driving the loop with pump_events.

If you were to initially start running a loop with pump_events and get past dispatching StartCause::Init and set loop_running = true then technically you could then try and use run_on_demand which would now have an un-expected initial state.

Instead of trying to handle that unusual / unexpected mixing of pump_events and run_ondemand these returned an error in that case instead.

@kchibisov
Copy link
Member

I don't think that it's an issue actually? Like you can probably start with pump events for one iteration, but then continue with run or run_on_demand?

@kchibisov
Copy link
Member

At least it should kind of work now.

@rib
Copy link
Contributor

rib commented Jan 29, 2024

Like you can probably start with pump events for one iteration, but then continue with run or run_on_demand?

Yeah I think it's just that you'd get ambiguous semantics to try and do something like that, e.g. considering that you probably won't get a StartCause::Init event.

Since it's a weird case, I think my preference at the time was to throw an error instead of having to think about what semantics to promise users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - api Design and usability
Development

Successfully merging this pull request may close these issues.

5 participants