Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126673 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id EB4771A00BC for ; Sun, 9 Mar 2025 09:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741513867; bh=NPRksPqN5+hmZK6kjM5ms8hEkoj0+Nc/p68vJ7xIMaE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=csAq1hDTTlIYt26f18Yj/o0n0iviOudVqWlwrtR44iD5rRV3kpIvfwrRSEkE1YHvO QndKU45erp1Mk9sxUJsWO0KnWGscr0TZ7qE8iDe22kiwh2YTF9GUvEF25E4jsE9HUm ngMnQDGujCKFc1hvrqVCCWYtDB+D7Mt4ZfXe+UZ6Acfe4h/Qb0ar26cdymtE7PtbSX /2FvDsXQZRQpIH0uHdi2YPd2LKyPpIOt3ez+zLH+bLxZ6W5UUi8FM5Qp+SMo5AVExj 7PnGXbBudT9Ak7PIMIKbFJHfsBc7amPA3Zuhoai8ov/ZhOE3oNsvO7Ysl/P9eonimD 9yXj2zTM/68Pw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3CB4818004A for ; Sun, 9 Mar 2025 09:51:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 9 Mar 2025 09:51:06 +0000 (UTC) Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e637edaa652so530297276.1 for ; Sun, 09 Mar 2025 01:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741514020; x=1742118820; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=yFMoNV4h5HUWI0XmR2qqk0EJA4SJxjGyuKf6Q+Fd4Dg=; b=Nq0dIlkju+VVlWH8GCKJ8Z9qNLhGSbfaEyJyCdF4fCezmMIrpbyn8aRtu3yccmsrn9 jP7J9kfKEof8+vU+5bdCZtYgOlTOcjufckYq02r46BVnqTX0auXaZrAj1ylpxPMnFmJk 5eGneE7NX90FrNscULgwNxhuTCW9K7P1oHh/886ILEBhacv+4SHvHk6O83fn2G/0Ia/n Y3IZzZV6cC7tfeg7qnGYk+f+7Pf+C75Kk8/nB9sypVUcYGIZ5uDPf2tpVN2WngQD4P0/ 3Mel93l+k6cmlgmLwC6vdv75a1PzTqRifcQcMDIH/FYFI/J4+7q1nPv0n6yFDvWwM2JS JHTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741514020; x=1742118820; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yFMoNV4h5HUWI0XmR2qqk0EJA4SJxjGyuKf6Q+Fd4Dg=; b=LKCbgg+fZE8xCz/rqPsjiafXokf1QrjYZpvsT7+s/45WCp02YFFkDmHZ+Q7DkB7gI+ +cAgS8srZEaoV9VJQymCuRBVr8ZtMCSXLh+hz79ZNMl6Y3LttRLUFnlB5yfUdin2G2NG +tS5Mb10Xssb52Xh9GnhAAwsXLfcmLO6duDhuM9+qDD9lmxOAqAs8IQX4ulsvgs6KMxC aT4hv7vUX9A32XxTEf6mBDAjPcYsSBEIaZMXxHsschER0mYimmP1cW633LlxsbXFKTci L28bByTorc5+ecIzmIxtOTni74xy/0QeBppalVqWrnUM+4PLt4ykKLDRDNU2FS5R3EDD 8+YQ== X-Forwarded-Encrypted: i=1; AJvYcCVue9gPBqYyEacUlliv9ys0eK6wsyWVgtLkdokvBTKgFwzlNW9GiQ4imB0DlAyzz59emEORPsjPOjk=@lists.php.net X-Gm-Message-State: AOJu0YyPFDTfbJy2Ikr4FSd2dE5Ma2ebKGWnG8s2D1UzKVVoXMWDx/Xh oE+zHu5Bnu8udBet9HGnbccn+b5hAReqezGG0FkmJyOzEF7xpe4RpRrvrxrsfpKeH6RG7UGDD3v EA009Cb0ZbnBxGl2TqtfYmR7/yArDQFuNEnM= X-Gm-Gg: ASbGncvqN8ujqNlor7G//XImVCm+z6IVkNi/QIBZV5LAzj3L4uAQO0JQNSibdhKEvvF VShGpPhZUezxWlq1VisghvcgmdB1uTMzeGAhsZMqTID5RNr+UGZQCCUaag0YyQK77gpM255NiQ/ Sy50+97bjHxt7R4Cf3d5g73Dknmw== X-Google-Smtp-Source: AGHT+IFgj8kULtoG4l8J7oRFDCvRt3BcHDfueUzHWTWZiMpilHhyY0uwonYlqESDQ7qkvXgDsKBJhVNvc3QHboT7NsE= X-Received: by 2002:a05:6902:2702:b0:e5b:1453:d2e4 with SMTP id 3f1490d57ef6-e635c143e65mr12160291276.11.1741514020200; Sun, 09 Mar 2025 01:53:40 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <9964db8c-0ffe-43d5-8246-47fc76b07180@app.fastmail.com> <78a03dd0-fd4a-4f4a-ad8a-37e5704f06fc@app.fastmail.com> <08c8ad0b-e8f4-46e3-99f0-b80748d40b89@app.fastmail.com> <07973EAE-2D83-47A8-8FA0-84286C77C02B@rwec.co.uk> <48d66433-3ae9-4895-8361-7c81a0a3670d@app.fastmail.com> <8599eb8b-d4a3-4cb8-899a-25b134e0d64d@gmail.com> <74c4c726-63aa-44e0-84c9-840e13a65a4f@gmail.com> <9b7ab30f-5ed6-400d-b941-1291e9185286@app.fastmail.com> <9a2e81e8-3534-455b-879a-5a45c85b3ba7@gmail.com> <3384e8b2-5fee-420f-b8cc-e54bba0884db@app.fastmail.com> In-Reply-To: <3384e8b2-5fee-420f-b8cc-e54bba0884db@app.fastmail.com> Date: Sun, 9 Mar 2025 11:53:29 +0200 X-Gm-Features: AQ5f1JqFllXuENY-wL-Mp8l3854AP0DuTgjSZBjwIC9gGtfMF3pRDyJZL5W4KvU Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC To: Rob Landers Cc: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= , Daniil Gentili , PHP internals Content-Type: multipart/alternative; boundary="0000000000008bad24062fe5d421" From: edmond.ht@gmail.com (Edmond Dantes) --0000000000008bad24062fe5d421 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > Maybe, we could create a different version of fibers ("managed fibers", maybe?) distinct from the current implementation, with the idea to deprecate them in PHP 10? > Then, at least, the scheduler could always be running. If you are using existing code that > uses fibers, you can't use the new fibers but it will "just work" if you aren't using the new fibers (since the scheduler will never pick up those fibers). > Yes, that can be done. It would be good to maintain compatibility with XDEBUG, but that needs to be investigated. During our discussion, everything seems to be converging on the idea that the changes introduced by the RFC into Fiber would be better moved to a separate class. This would reduce confusion between the old and new solutions. That way, developers wouldn't wonder why Fiber and coroutines behave differently=E2=80=94they are simply different classes. The new *Coroutine* class could have a different interface with new logic. This sounds like an excellent solution. The interface could look like this: - *suspend* (or another clear name) =E2=80=93 a method that explicitly h= ands over execution to the *Scheduler*. - *defer* =E2=80=93 a handler that is called when the coroutine complete= s. - *cancel* =E2=80=93 a method to cancel the coroutine. - *context* =E2=80=93 a property that stores the execution context. - *parent* (public property or getParent() method) =E2=80=93 returns the= parent coroutine. (*Just an example for now.*) The *Scheduler* would be activated automatically when a coroutine is created. If the index.php script reaches the end, the interpreter would wait for the *Scheduler* to finish its work under the hood. Do you like this approach? --- Ed. --0000000000008bad24062fe5d421 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>=C2=A0
>=C2=A0 Maybe, we could create a different version of fibers ("managed fibers&= quot;, maybe?) distinct from the current implementation, with the idea to d= eprecate them in PHP 10?
> Then, at least, the scheduler could alway= s be running. If you are using existing code that
> uses fibers, you = can't use the new fibers but it will "just work" if you aren&= #39;t using the new fibers (since the scheduler will never pick up those fi= bers).
>

Yes, that can be done. It would be good t= o maintain compatibility with XDEBUG, but that needs to be investigated.=C2= =A0=C2=A0

During our discussion, everything seems = to be converging on the idea that the changes introduced by the RFC into Fiber would be better moved to a separate class. This would redu= ce confusion between the old and new solutions. That way, developers wouldn= 't wonder why Fiber and coroutines behave differently=E2= =80=94they are simply different classes.

The new Coroutine class could have a different interfac= e with new logic. This sounds like an excellent solution.

The interface could look like this:

  • suspend (or another clear name) =E2=80=93= a method that explicitly hands over execution to the Scheduler.
  • defer =E2=80=93 a handler that is called = when the coroutine completes.
  • cancel =E2=80=93 a method to cancel the c= oroutine.
  • context =E2=80=93 a property that stores = the execution context.
  • parent (public property or getParen= t() method) =E2=80=93 returns the parent coroutine.

(Just an example for now.)

The Scheduler would be activated automatically when a c= oroutine is created. If the index.php script reaches the end, = the interpreter would wait for the Scheduler to finish its= work under the hood.

Do you like this approach?

---

Ed.

--0000000000008bad24062fe5d421--