Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126659 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 1B91A1A00BC for ; Sat, 8 Mar 2025 20:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741467283; bh=OJ0XyHQ3qNoc+dHiKE6zHUmwc4EJ61uqZ4/e9ccjSJY=; h=Date:From:To:Subject:In-Reply-To:References:From; b=EQbi8+f6JqMrifuQftyHOwprKFjDvwrNmAynzdMCAZmLDt6ojKq3FnR4ItODZC34Y 1bGAxQepoNc7YNhLIoyholNH+V/uFYQ3OG1ov6Juj627smrK2Kq+SF7ojXzHW1VgAW 17KBJQyyxSoF2AptY14jIgMotAau8YtoHB++Vvt8pu65wxvwQ9vMtMayPGgRqPisDk tgJy3FdKs7lU90ZiOddOQvcDbfMlMmw695XdcoREKkOcXni80gayOd6Zj6hagCjkFH lX9uGRSmU5gqMOS+UrtazwksMqGzIhiIeqJEqRG0jZHYlxl4THxhSf4qQpZhmcrA6N 7gxrwUjG4LUQw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E0268180088 for ; Sat, 8 Mar 2025 20:54:42 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-a2-smtp.messagingengine.com (fout-a2-smtp.messagingengine.com [103.168.172.145]) (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 ; Sat, 8 Mar 2025 20:54:42 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id E4056138147B for ; Sat, 8 Mar 2025 15:57:16 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Sat, 08 Mar 2025 15:57:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1741467436; x=1741553836; bh=OJ0XyHQ3qNoc+dHiKE6zHUmwc4EJ61uqZ4/e9ccjSJY=; b= SbXNYQTv7JmxrFmhmVoefjRpOUO12NKNbBm/imQkQcnuPyTW2HOPss071gjMKwBX eaYUrvf88rGTo4nsQzoaEZjM4qtPi+HX8ebrecYzSuLRU5tKgH/N2gnIxgI56nAA xHBbUvceAgerzvs1bM6I/YR/scybXpNUM3bOrhlSmZnjrpb6XRq+WzqmqXX+I37t Lx0PidITr9NGoayCtzYCFBJYwMBvxNwt4ESnLb4x6VXL4HKgwH3Vmfn4MCf0n52P CzRvCWR4c4aGU0KTcTvzGd+FsQ+MAzNSJz7JpW39e7s6sa4u7+HoJOt0RspahAYp RLUnoZy4fmZtkduqDTFNZg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1741467436; x=1741553836; bh=O J0XyHQ3qNoc+dHiKE6zHUmwc4EJ61uqZ4/e9ccjSJY=; b=B+u2YVvGBbUlyVFRW 4btHlkeNSbA4QFuoN7w58iAiD8o1SoOsLjk36giRTqDbFFIHyNKNZxGSSiDMrdQZ ebAOx2yF7I1isW9/JqQHJRuWBHG/jwMnqDO354NmLYzF9ZpjZ+VIMIMV1qs9V/tC hIrPhHksya5I8FCeuSBbM8BuVUsl5764R2E9rLC1FuUY69SAx5tIKVOdLUOqjjXr Uyf2cOkGXv4ePBYK5kjiUJyQPLZuFi6engZQTHTq6brXm+riI3HPhQ2to6e+a2YX jUs4rRWvJ/cgk1zQyavmeMVsFJglGxnnPJe9f5LYwoyu/TvQms+etB70trHqCdxI KgCbw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduudegheejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhf fvufgfjghfkfggtgfgsehtqhhmtddtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeehleffteeigfevudetfedugedtudevledugeeugeelheei hfehgfdtkeevvefgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 8 Mar 2025 15:57:16 -0500 (EST) Date: Sat, 08 Mar 2025 20:56:12 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] PHP True Async RFC User-Agent: K-9 Mail for Android In-Reply-To: <74c4c726-63aa-44e0-84c9-840e13a65a4f@gmail.com> 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> Message-ID: <77DC5F50-531D-49E8-8BE2-504A19CB5FFD@rwec.co.uk> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 8 March 2025 13:38:30 GMT, Daniil Gentili wrote: > >> The async block as I'm picturing it has nothing to do with function col= ouring, it's about the outermost function in an async stack being able to s= ay "make sure the scheduler is started" and "block here until all child fib= ers are either concluded, detached, or cancelled"=2E > >There's no need for such a construct, as the awaitAll function does preci= sely what you describe, without the need to introduce the concept of a chil= d fiber and the excessive limitation of an async block that severely limits= concurrency=2E No, it's not quite that either=2E The scenario I have in mind is a web / n= etwork server spawning a fiber for each request, and wanting to know when e= verything related to that request is finished, so that it can manage resour= ces=2E If we think of memory management as an analogy, awaitAll would be equivale= nt to keeping track of all your memory pointers, and making sure to pass th= em all to free before the end of the request=2E The construct we're discuss= ing is like a garbage collection checkpoint, that ensures all memory alloca= ted within that request has been freed, even if it wasn't tracked anywhere= =2E Written in ugly functions rather than concise and fail-safe syntax, it's s= omething like:=20 $managedScope =3D new ManagedScope; $previousScope =3D set_managed_scope( $managedScope ); spawn handle_request(); // inside here any number of fibers might be spawn= ed $managedScope->awaitAllChildFibers(); // we don't have the list of fibers = here, so we can't use a plain awaitAll set_managed_scope( $previousScope ); unset($managedScope); It's certainly worth discussing whether this should be mandatory, default = with an easy opt-out, or an equal-footing alternative to go-style unmanaged= coroutines=2E But the idea of automatically cleaning up resources at the e= nd of a task (e=2Eg=2E an incoming request) is not new, and nor is arrangin= g tasks in a tree structure=2E I would also note that the concept of parent and child fibers is also usef= ul for other proposed features, such as cascading cancellations, and having= environment-variable style inherited context data=2E None of those is *ess= ential*, but unless there are major *implementation* concerns, they seem li= ke useful features to offer the user=2E Rowan Tommins [IMSoP]