-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add suspension listeners #2
Conversation
This breaks with the additional suspensions we've introduced for event loop callbacks now. I think this should be solved with a core / extension API in PHP itself rather than Revolt. |
The event loop callback fiber does not break this mechanism. The fiber switch when invoking an event loop callback is essentially considered part of the event loop fiber from the perspective of this API. Entering the callback is similar to entering a new fiber created by However, addressing it from within PHP itself may be a better solution. As this does not introduce a BC break, we are free to introduce this much later as we explore our options. |
96cee1b
to
ffad099
Compare
Note that I'm not entirely sure this is necessary myself. I wanted to propose a solution though and see what others thought. |
This is equivalent to the interface change in reactphp/async#15 to allow different implementations. This also allows decorating `Suspension` to implement listeners like proposed in #2.
This is equivalent to the interface change in reactphp/async#15 to allow different implementations. This also allows decorating `Suspension` to implement listeners like proposed in #2.
This is equivalent to the interface change in reactphp/async#15 to allow different implementations. This also allows decorating `Suspension` to implement listeners like proposed in #2.
#23 converts |
Closing this as it can be implemented in a separate library. |
Fatal error: Uncaught FiberError: Cannot suspend in a force-closed fiber in /srv/app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:441 Stack trace: #0 /srv/app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(441): Fiber::suspend(Object(stdClass)) revoltphp#1 /srv/app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(567): Revolt\EventLoop\Internal\AbstractDriver->invokeMicrotasks() revoltphp#2 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}() revoltphp#3 {main} thrown in /srv/app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php on line 441
This PR allows user-definable hooks to be invoked when a fiber (or main) is suspended or resumed.
The motivation is to allow libraries/apps to implement behavior such as that requested in amphp/amp#354 if so desired.
This is designed to be lightweight so applications that do not use these hooks do not incur a large performance overhead.