Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99719 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62682 invoked from network); 3 Jul 2017 17:17:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2017 17:17:51 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.219 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.219 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.219] ([81.169.146.219:15788] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/B6-15131-F3C7A595 for ; Mon, 03 Jul 2017 13:17:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1499102268; l=4291; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=f7EJiFtQoF+CtlK67Vw/PtYp2jPvHi/gb3ZRsF1eplc=; b=rUeCNAp7rijSg7b8hk/Y/vbMunEEpDYHibiCVn7WgQCDAYyZP3oS/VLXY+SHEmiDbt pYBAtAlzUaeUKO3mt+E/GA1PKZX5Xkkv3ZOZ9Ec5DaNiFIOoh0lge5WoDBmWM3uiVugk Vq5xVJoQN/AJFGcSMMGLEOIBPtP6DKZWJBXzg= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuoNHBqX53Q== X-RZG-CLASS-ID: mo00 Received: by mail-oi0-f41.google.com with SMTP id l130so86521474oib.1 for ; Mon, 03 Jul 2017 10:17:48 -0700 (PDT) X-Gm-Message-State: AIVw112m7tgycvz9+6hAaF8beUeIYm/cwZKiMYoL8wSPuYiFyjULbnAa If+BROkXVTcuXouM7NySiZwk9zSk3w== X-Received: by 10.202.206.212 with SMTP id e203mr13661952oig.168.1499102267326; Mon, 03 Jul 2017 10:17:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.81.135 with HTTP; Mon, 3 Jul 2017 10:17:46 -0700 (PDT) In-Reply-To: References: Date: Mon, 3 Jul 2017 19:17:46 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Andreas Hennings Cc: Sara Golemon , PHP internals Content-Type: multipart/alternative; boundary="001a113adef0204d0405536cf2d9" Subject: Re: [PHP-DEV] "Reader" as alternative to Iterator From: me@kelunik.com (Niklas Keller) --001a113adef0204d0405536cf2d9 Content-Type: text/plain; charset="UTF-8" 2017-07-03 17:50 GMT+02:00 Andreas Hennings : > On Mon, Jul 3, 2017 at 9:09 AM, Niklas Keller 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. > Indeed, it can do both at the same time. > I assume this is to achieve the concurrency. Not exactly, it "outputs" a promise and "inputs" the resolution value or exception once that promise resolves. Regards, Niklas --001a113adef0204d0405536cf2d9--