Re: [PHP-DEV] [RFC] Fiber support (again)

2018-04-30 Thread Rasmus Schultz
- Using Fiber::resume() to initialize the fiber and resume feels >>> awkward. Separate methods again would be better here, perhaps >>> Fiber::init(...$args) and Fiber::resume($send). >>> >>> All Fiber created with a suspended status. So make resume to do both the >>> init and resume >>> do

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-04-29 Thread Peter Kokot
Hello, I've only briefly tested current implementation and from my point of view, people new to the concept of coroutines, the async/await syntax might be much more readable and understandable what is happening behind and why this might be useful to have in the core. But yes, I'm sure there is a

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-10 Thread Niklas Keller
>> 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

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-10 Thread 吕海涛
> On Feb 10, 2018, at 22:49, Niklas Keller wrote: > >> Hi, all, >> >> I have updated the RFC https://wiki.php.net/rfc/fiber >> >> changes list: >> >> - introduce the `throw(Exception $exceptin)` API >> - record issues discussed > > What about my suggestion of making PHP's

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-10 Thread Niklas Keller
> Hi, all, > > I have updated the RFC https://wiki.php.net/rfc/fiber > > changes list: > > - introduce the `throw(Exception $exceptin)` API > - record issues discussed What about my suggestion of making PHP's main() automatically a Fiber, which avoids Fiber::yield() being used outside of a Fiber,

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-10 Thread Haitao Lv
Hi, all, I have updated the RFC https://wiki.php.net/rfc/fiber changes list: - introduce the `throw(Exception $exceptin)` API - record issues discussed > On Feb 9, 2018, at 08:12, Haitao Lv wrote: > >> >> On Feb 9, 2018, at 06:22, Niklas Keller wrote: >>

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-09 Thread Niklas Keller
2018-02-09 21:53 GMT+01:00 Björn Larsson : > Regarding these potential new keywords await & async. > Any need to look into how Hacklang uses these keywords? > Could there be portability aspects on the functionality in > itself? No, there's no need to look at Hacklang

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-09 Thread Björn Larsson
Den 2018-02-09 kl. 12:48, skrev Niklas Keller: We have started building a PoC library on top of Fibers, see https://github.com/amphp/green-thread/blob/7bd3470e7986169372d5e9c39500f3652091b512/src/functions.php . We'd like to avoid the additional `await()` function and rather directly couple

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-09 Thread Niklas Keller
> > > The language should offer a sane API, not the absolute minimum required > to > > work for these things. > > The Ruby's Fiber do offer a live? method but does not have a getStatus > method. > The Lua's coroutine only offer a status method. > > So do we really need to offer three additional

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-09 Thread S.A.N
This has already been discussed in github Fiber::resume() https://github.com/fiberphp/fiber-ext/issues/7 Fiber::throw() https://github.com/fiberphp/fiber-ext/issues/6 Keywords - async/await https://github.com/fiberphp/fiber-ext/issues/10 I believe that current API is normal for the Pecl ext,

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-08 Thread Haitao Lv
> On Feb 9, 2018, at 06:22, Niklas Keller wrote: > >> >>> - How do you determine when a fiber has returned? Looking at the source, >> it appears Fiber::status() must be used, comparing against constants. >> Separate methods similar to Generator would be better IMO. e.g.: >>

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-08 Thread Niklas Keller
> > > - How do you determine when a fiber has returned? Looking at the source, > it appears Fiber::status() must be used, comparing against constants. > Separate methods similar to Generator would be better IMO. e.g.: > Fiber::alive(), Fiber::suspended(), Fiber::running() > > Offering methods like

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-08 Thread Haitao Lv
> On Feb 8, 2018, at 12:18, Aaron Piotrowski wrote: > >> >> On Feb 7, 2018, at 7:05 PM, Haitao Lv wrote: >> >> Hi internals, >> >> I propose to introduce the Fiber feature AGAIN. >> >> The main purpose of the RFC is to introducing a lightweight stackful

Re: [PHP-DEV] [RFC] Fiber support (again)

2018-02-07 Thread Aaron Piotrowski
> On Feb 7, 2018, at 7:05 PM, Haitao Lv wrote: > > Hi internals, > > I propose to introduce the Fiber feature AGAIN. > > The main purpose of the RFC is to introducing a lightweight stackful > coroutine support for PHP and make it possible to write non-blocking code in > the