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

Support async/await in Mojo::EventEmitter #1452

Closed
wants to merge 1 commit into from
Closed

Conversation

kraih
Copy link
Member

@kraih kraih commented Dec 27, 2019

Currently using Mojo::EventEmitter with async/await is very awkward, since the promises returned by async functions need to be referenced manually. This PR is a possible solution, but there is a performance cost. We use Mojo::EventEmitter very extensively in Mojolicious (and countless 3rd party modules), so it is hard to say if this could become a real problem.

Here are before and after example apps.

@kraih
Copy link
Member Author

kraih commented Dec 27, 2019

I'm very unsure what the correct way for handling this is. The finally hack could also be applied at the Mojo::Promise async protocol level, but that essentially disables a feature of Future::AsyncAwait to detect unhandled promises.

@kraih
Copy link
Member Author

kraih commented Dec 27, 2019

I'm bringing this up so early because i'm fairly certain many of our users will want to use async/await with WebSockets.

@kraih
Copy link
Member Author

kraih commented Dec 27, 2019

After thinking some more about this, the impact on the Mojo::IOLoop::Stream layer really worries me. Some events are very relevant to overall performance.

@kraih
Copy link
Member Author

kraih commented Dec 27, 2019

I think we can rule out this solution, it's pretty terrible.

@kraih kraih closed this Dec 27, 2019
@kraih kraih deleted the async_events branch May 13, 2020 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant