Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113602 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62046 invoked from network); 18 Mar 2021 14:01:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Mar 2021 14:01:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 534061804DC for ; Thu, 18 Mar 2021 06:55:56 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 18 Mar 2021 06:55:55 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id 75so4720222lfa.2 for ; Thu, 18 Mar 2021 06:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X+o2ApKRKa1yWLge0ZqOfFBOf0zKtoAHYCKOAWWam1E=; b=IcvQPMzlXOKVwXBaGrSSEpKbU/64G0hOk1kwZFXG69Zs/glkOb+J6ler9Jo/5QhVdl LrhfeRJryq6u8GXktr0zg4C1L8XmnV5zAaKzz8Rz398OD+ba4rHGE49VIn8vlVTCSS5n mdrkQ4CBB4Z1OKCc9wzUdMkZiGK+B05apGxu1ofsCs3juw2Eff44mNW9N9DQq4iDSOmK 6nkgJm0LgtAPYeYdU2NCQeitksvCG/Wu/pDPFx6WbIHPjLbGXLpzOblaeY2bO7CCZD9H h9EW4Zunys56qM//d8w9w5vzwtUIspDnyaKv3SFzpr3qG/Ko+sPLXqASbwuhvHIj+Fn5 FDMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X+o2ApKRKa1yWLge0ZqOfFBOf0zKtoAHYCKOAWWam1E=; b=bse7nw0fuEjR4OUZx2OmC64FXq1pdtN3DxM2dQCqUGCHUWsKbk2ozrR/2OF6RrZ0Dm flw8SltRGo67jNVmFIYpXEELtX3TkKFHqjQSSAWYQ+v591Ov0Z/AQjhcV5nOrIZ07x6X olOh+W79b0KBg/TwSdFRydVbkGa2uPgoIdqcGa63t+eVn08FN7KVKq16mvtFqdwp8BCP C4DSSLnByIq/rQ/FjajC2AeyOOozvM9FadjVo9dfMr5P394EGTnkcLETqzi00n+c/dmK Shn/vutDR/KvbJ5DxcLwO09/ULHSAPhQwRyx05WaNd3D7yWpYcWZLU2b1Osr4kwfnHNF ZANA== X-Gm-Message-State: AOAM533+8zgTB+WcT1rVGodicu4K4wGBS0pkt4VwfJtDTybL4jYimT0/ db6GZ7bUmNBaMqi0m3bIjCoMKu8GozgcGZWjbA== X-Google-Smtp-Source: ABdhPJx+qLBlHte7WvYOmR9Mq7VGwMdE7UMMcD/VCNZrNA1BOoPZXGflZW4EiUSt1GJaXfi0dMxsY33y1a8wh8zLzR0= X-Received: by 2002:ac2:57c9:: with SMTP id k9mr5541796lfo.119.1616075750060; Thu, 18 Mar 2021 06:55:50 -0700 (PDT) MIME-Version: 1.0 References: <70951423-5e77-c150-6dce-dd3c62f8dc8b@php.net> <0b994a60-7970-605b-1657-d6ee732690e5@gmx.de> <5C73A1DE-E563-4F69-B8C7-6506F81D7345@trowski.com> In-Reply-To: Date: Thu, 18 Mar 2021 14:55:39 +0100 Message-ID: To: Josh Di Fabio Cc: Peter Stalman , php internals Content-Type: multipart/alternative; boundary="00000000000003357e05bdcff592" Subject: Re: [PHP-DEV] [VOTE] Fibers From: guilliam.xavier@gmail.com (Guilliam Xavier) --00000000000003357e05bdcff592 Content-Type: text/plain; charset="UTF-8" Hi, Guzzle's requestAsync() returns a promise, it does not > interrupt/suspend the callsite. For example: > > // this function is not interrupted/suspended -- it will return > synchronously > function doSomething() { > $this->guzzle->requestAsync(...)->then(... handle response here > ...); > echo "This will be printed before a response is received"; > } > > The following is similar to how one would implement an coroutine in > PHP today when using a library which implements a coroutine mechanism, > such as amphp. Note the yield statement which interrupts/suspends the > function: > > // this function will be suspended while the request is in flight > -- it will return after a response is received > function doSomething() > $response = yield $this->guzzle->requestAsync(...); > // do something with response here > echo "This will be printed AFTER the response comes back"; > } > > Note the difference between the two. Also note how, in both of the > above cases, the asynchronicity is explicit and the developer has > opted into it. Both of the above are different approaches to that > being proposed in this RFC (this is a design choice by the authors). > At the risk of sounding dumb: What would that code look like with fibers? Thanks, -- Guilliam Xavier --00000000000003357e05bdcff592--