Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100486 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31150 invoked from network); 9 Sep 2017 10:31:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Sep 2017 10:31:32 -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.161 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.161 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.161] ([81.169.146.161:24860] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/96-10715-103C3B95 for ; Sat, 09 Sep 2017 06:31:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1504953086; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=GI4UZimF21xJ5Ri7+uID+qarXgTieFxT3PzXqb4V0XU=; b=se7SNs60kPamfLb/ATHBHoNTUerKYTJD3vsvfB5xBILA7YpHlcDOunX8eFx8Kf/4m/ IaoNYCfMDoiNbQA0zM4ivL/i+hZeBZTf44SJUrHZ9noyk1DorHlnVmlg5WecfrmlgEg1 332AdM7owve8bf1rf9O2XKXjrc0JaFEpQ26d0= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuYROBqDwsAg= X-RZG-CLASS-ID: mo00 Received: by mail-yw0-f180.google.com with SMTP id s62so13039859ywg.0 for ; Sat, 09 Sep 2017 03:31:26 -0700 (PDT) X-Gm-Message-State: AHPjjUhxty8RBL+FVxaS3Dxo3zXM07Wtx6Wptt2N8CWiIi99U7iCzPYE P12lg6+3E1Za2oCkTb27O+sT+/kl1Q== X-Google-Smtp-Source: AOwi7QDn5iPsW1F5V5rvOgQfWN06lZ+rNQI4SBZpoecGYJwd4DHaC5K4JZUEKGKm8AjehgLtYxJQ9tTumcyBE5+xiUk= X-Received: by 10.37.212.72 with SMTP id m69mr2366536ybf.192.1504953086200; Sat, 09 Sep 2017 03:31:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.224.146 with HTTP; Sat, 9 Sep 2017 03:31:25 -0700 (PDT) In-Reply-To: References: <7E991FBB-C115-4AB9-B904-EBE7C0F24089@lvht.net> <8DB5D7F2-CB7A-4324-AB9F-D9934DD9C108@lvht.net> Date: Sat, 9 Sep 2017 12:31:25 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Haitao Lv Cc: Rowan Collins , PHP Internals Content-Type: multipart/alternative; boundary="94eb2c0794701b58400558bf326b" Subject: Re: [PHP-DEV] add Fiber (sackful coroutine) support From: me@kelunik.com (Niklas Keller) --94eb2c0794701b58400558bf326b Content-Type: text/plain; charset="UTF-8" 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 a generator from > its sub function call. So if we introduce fiber, these wrapper is needless. We could easily support yielding generators and auto-wrapping them in the coroutine implementation, but not every generator is a coroutine. And generators are an implementation detail, it doesn't make sense to force everything to be a generator. > > > > > I don't see an event loop or promises being built-in soon, but something > > like that could provide `async` with userland magic. Not the best thing, > > but maybe better than preprocessing, don't know. > > Fiber is asymmetric coroutine, and the PHP kernel has no duty to schedule > them. So a built-in event loop is no needed. I'm actually thinking about bringing our promise + coroutine implementation to php-src. `await` could be used to automatically convert generators into coroutines, which implement promise. It would be mostly syntactic sugar for the current Amp implementation, because all these wrappers are gone, but the implementation details of something being a coroutine stays hidden behind a promise interface. Regards, Niklas --94eb2c0794701b58400558bf326b--