On Mon, Jul 3, 2017 at 9:09 AM, Niklas Keller <m...@kelunik.com> wrote:
>
> Hey Andreas,
>
> what you're trying to do here seems to be premature optimization. While you
> save a bunch of method calls, your I/O will be the actual bottleneck there.
> It's entirely fine to implement such logic in userland.

I will let this stand unchallenged, until I have some reproducible data..

>
> Amp has a similar interface for its streams, but those have only string|null
> as types. If you want to allow all values, you either need a second method
> or need to wrap all values in an object.
>
> http://amphp.org/byte-stream/#inputstream +
> http://amphp.org/amp/iterators/#iterator-consumption

This library looks interesting.
It seems to do a lot more than I currently need, with its concurrency approach.
I am a bit puzzled by the yield keyword in this code:

 while (($chunk = yield $inputStream->read()) !== null) {
    $buffer .= $chunk;
}

In my experience with generators so far, you either use yield for
sending or for receiving. So either "yield $value;" or "$value =
yield;" In this case it seems to do both.
I assume this is to achieve the concurrency.

(This is not an argument for or against anything, just an observation)

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to