>> There would also need to be something that stops the script execution >> as soon as there's no non-suspended Fiber anymore. > > As you pointed out, the main process cannot be a Fiber because it need to > schedule other fibers.
The conclusion is wrong. There just needs to be a way to access this fiber, e.g. Fiber::getMain(). >> >> Regarding the internal calls: A core dump / segfault in case of >> Fiber::yield() inside an internal function is unacceptable. It doesn't >> give the user any clue what's wrong. Instead, an exception could be >> thrown from Fiber::yield(), which just bubbles up then. Full support >> for internal functions could be added at a later point then. > > It is impossible to solve this issue before we get a pure stackless Zend VM. > > If this feature can be merged into PHP 7.3, we could introduce a new counter > to record the zend vm nested level. Every time you enter an internal call, > let zend increment the counter, and decrement it when out. > > When we create a fiber, we remember current vm nested level. When zend execute > Fiber::yield,it will throw an error if the current vm nested level is not > equal to the original one. > > This feature cannot be implemented without changing the zend vm code base. You're proposing this as language feature, not as an external extension, so that is entirely fine and actually the reason why this should be in core instead of an external extension. Regards, Niklas -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php