Re: add Fiber (sackful coroutine) support

From: Date: Sat, 09 Sep 2017 10:31:25 +0000
Subject: Re: add Fiber (sackful coroutine) support
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-100486@lists.php.net to get a copy of this message
2017-09-09 8:07 GMT+02:00 Haitao Lv <i@lvht.net>: > > > On 1 Sep 2017, at 22:25, Niklas Keller <me@kelunik.com> wrote: > > > > A potential way around that (might be a stupid idea I just had): Allow > > defining "wrappers" per file, that auto-wrap marked functions. > > Amp need these wrapper functions because we cannot yield a generator from > its sub function call. So if we introduce fiber, these wrapper is needless. We could easily support yielding generators and auto-wrapping them in the coroutine implementation, but not every generator is a coroutine. And generators are an implementation detail, it doesn't make sense to force everything to be a generator. > > > > > I don't see an event loop or promises being built-in soon, but something > > like that could provide async with userland magic. Not the > > best thing, > > but maybe better than preprocessing, don't know. > > Fiber is asymmetric coroutine, and the PHP kernel has no duty to schedule > them. So a built-in event loop is no needed. I'm actually thinking about bringing our promise + coroutine implementation to php-src. await could be used to automatically convert generators into coroutines, which implement promise. It would be mostly syntactic sugar for the current Amp implementation, because all these wrappers are gone, but the implementation details of something being a coroutine stays hidden behind a promise interface. Regards, Niklas

« previous php.internals (#100486) next »