-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Automatically run Loop at end of program (autorun) #232
Conversation
da3412f
to
4b7727e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've previously briefly discussed this, and I'd recommend against introducing this. Application registered shutdown functions won't be run if they're registered inside event loop watchers and a fatal error or explicit exit;
happen, see e.g. https://3v4l.org/duM4S.
The autorun functionality is a new feature that will only be used when switching to the Other than that, I don't see how this would affect real-world use cases in any negative way. I've added a bunch of test cases that verify common application setups work as expected (either using the new style or the existing style). If you feel anything's missing, I'm happy to look into this and provide additional test cases 👍 |
Rebased on |
Connector
optional
clue/reactphp-socks#100
When using the
Loop
class, it will automatically execute the loop at the end ofthe program. This means the following example will schedule a timer and will
automatically execute the program until the timer event fires:
As of
v1.2.0
, we highly recommend using theLoop
class this way and omitting anyexplicit
run()
calls. For BC reasons, the explicitrun()
method is still valid and may still be useful in some applications, especially
for a transition period towards the more concise style.
If you don't want the
Loop
to run automatically, you can either explicitlyrun()
orstop()
it. This can be useful if you're usinga global exception handler like this:
This is a pure feature addition that works across all loops and does not affect BC.
Builds on top of #226, #229 and #231