Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-09 Thread Niklas Keller
2017-09-09 8:07 GMT+02:00 Haitao Lv : > > > On 1 Sep 2017, at 22:25, Niklas Keller 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

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-09 Thread Haitao Lv
> On 9 Sep 2017, at 14:27, Haitao Lv wrote: > >> I note that the examples there all implement it not as a keyword, but as a >> library function, which maybe makes more sense: whereas "yield" turns a >> function declaration into a generator declaration, "Fiber\yield", as we >> might call it, i

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-08 Thread zixu mo
the best corotine . must be golang go and chan. very easy to use. non blocking. On Sat, Sep 9, 2017 at 2:28 PM +0800, "Haitao Lv" wrote: > On 2 Sep 2017, at 20:19, Rowan Collins wrote: > > On 1 September 2017 14:02:29 BST, Haitao Lv wrote: >> >> Fiber is a lightweight thread. P

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-08 Thread Haitao Lv
> On 2 Sep 2017, at 20:19, Rowan Collins wrote: > > On 1 September 2017 14:02:29 BST, Haitao Lv wrote: >> >> Fiber is a lightweight thread. Please see >> https://en.wikipedia.org/wiki/Fiber_(computer_science) >> And ruby support Fiber. Please see >> https://ruby-doc.org/core-2.4.1/Fiber.html >

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-08 Thread Haitao Lv
> On 1 Sep 2017, at 22:25, Niklas Keller 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 i

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-02 Thread Rowan Collins
On 1 September 2017 14:02:29 BST, Haitao Lv wrote: > >Fiber is a lightweight thread. Please see >https://en.wikipedia.org/wiki/Fiber_(computer_science) >And ruby support Fiber. Please see >https://ruby-doc.org/core-2.4.1/Fiber.html Ah, thanks, that makes more sense now. I note that the examples

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-01 Thread Niklas Keller
2017-09-01 15:02 GMT+02:00 Haitao Lv : > > > On 1 Sep 2017, at 20:45, Rowan Collins wrote: > > > > Is this your own invention, or is the name and semantics based on some > existing language or computer science theory? "Fiber" makes me think of > strings, rather than coroutines, so maybe I'm missi

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-01 Thread Haitao Lv
> On 1 Sep 2017, at 20:45, Rowan Collins wrote: > > Is this your own invention, or is the name and semantics based on some > existing language or computer science theory? "Fiber" makes me think of > strings, rather than coroutines, so maybe I'm missing a key metaphor here. Fiber is a lightwei

Re: [PHP-DEV] add Fiber (sackful coroutine) support

2017-09-01 Thread Rowan Collins
On 31 August 2017 15:28:36 BST, Haitao Lv wrote: >So I propose to introduce the sackful coroutine, aka Fiber, support for >PHP. Hi! Is this your own invention, or is the name and semantics based on some existing language or computer science theory? "Fiber" makes me think of strings, rather tha

[PHP-DEV] add Fiber (sackful coroutine) support

2017-08-31 Thread Haitao Lv
Hi, All, The generator has been introduced in PHP 5.5. And we can it pause a function execution. With these feature, we can schedule multi io task in userland without blocking. More details can be found at [Nikic]. And there is also some asynchronous frameworks like [AMP], which allow programe