Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126625 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 CD29A1A00BC for ; Fri, 7 Mar 2025 21:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741384278; bh=VjTa1+lDheHM0AaxI/2eQCNKuPGGJJDMvtErKXZxo74=; h=Date:Subject:To:References:From:In-Reply-To:From; b=NOmxdm9ZUq3DSuaU/hqNNluNXX2G8L0x6Nsz8nnwnd3MXNXsA6wnrRO9/+u/NU3xi PJImukL7qon01qirGpet8Ai2jVQmdgkwLPHe16roz1QB3B5t6B9FwQOTtnu1a2OFy0 BWFaaZT85YO8xeWQb6FzwKSuan6rDJojxZHzbffUPJVYbWV4Sf7xJ2O+MpqvBh50Bd /AGUZ4UVktt0Kn7Gwjn/SPoWaY1vqu5vqKlWClkFNNJcrS1SAyz0Ps1wE60OcISnNx 5v1ob0goo/u3F2szeIoSmFp3pruHeekQrQTpr99ugv0Dns8mkEcvQw2hWo3Ab5GEci 7i3P+c1d5x3ww== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 743191801D6 for ; Fri, 7 Mar 2025 21:51:17 +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 fhigh-b7-smtp.messagingengine.com (fhigh-b7-smtp.messagingengine.com [202.12.124.158]) (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 ; Fri, 7 Mar 2025 21:51:16 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id B766125401B0 for ; Fri, 7 Mar 2025 16:53:51 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Fri, 07 Mar 2025 16:53:51 -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=1741384431; x=1741470831; bh=98h/x9oL4cnQ4qcg0s40s3LeSRQyvLr8jHFe+zOv8DI=; b= HXTl0XHKLGEoIGZagzgEqYApIuzEwXk3AlotUyjgkvtAUpKwukWTOSWoDcdFCeh2 dcMAxXHQFYPq+7XKi96wH4/2XATj4j9Mmm20PCuxD7Lw7XBjyDbdrcmHoVTNFUlV llwE3CYzmJdmd9lIhaolNJ5APg8PnKBP9Xt9WOkTLpPthI+z9P9l/GsTcqh345J8 gZNx5C9ZdcNVeWLABnUeSGr4Xz5sNbcYKELU7GDfB4vwQbdwsl2KQhFRfF08Js/Q r2CIJ3rrFSKXlV2v7FyCHrBShT9lFwvYdsvAzQf03KCTwD9wU0Ju1UXHxzziRHWE 3l6IBxldNLDevlkXO+z2vw== 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=1741384431; x=1741470831; bh=9 8h/x9oL4cnQ4qcg0s40s3LeSRQyvLr8jHFe+zOv8DI=; b=LZ57uoZDo3hKPxbh/ 5W9dn9L9UPxs++eG0VUaGdr+VMxzyHYwZ4cPmMdz9bYL056wYKV5HaKI0zBFFeLR wWvuwPa/6qnlel2GqO1H7mxI0g+IaGyMdc28APJcRHoyu3vmhHyasj6O52axfNGN a7ys6MY5cV0FxT2CKwvh10vzypZjXGy0BJLoPlsqXTzuSBU3qEdwOky8RX9gKxWA 6Z0vD8c5ShHuwvnjUQsHP+uVVmVgb2bx4iA9XAtSGwVyW8iVznB/xANVAY3giVLi B5StpFObuwEe/C4FkDUVcRTUMhlE0lgmuyTgsT2j6HLV2yIPYlCu49DDv9dQQDs2 4uBXg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduuddujeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkff ggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeffkeevudffuddvheejvdefkeelfedtudegfeehjeduheeg ieduffeggeegveefheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 7 Mar 2025 16:53:50 -0500 (EST) Message-ID: <70413542-e1b1-42a5-ad65-44cd442a4454@rwec.co.uk> Date: Fri, 7 Mar 2025 21:53:47 +0000 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] PHP True Async RFC To: internals@lists.php.net 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> Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 07/03/2025 09:24, Edmond Dantes wrote: > Now, imagine a case where we need to create a coroutine not tied to > the parent. > To do this, we have to define a separate function or syntax. > > Such a coroutine is created to perform an action that must be completed, > even if the parent coroutines are not fully executed. > Typically, this is a critical action, like logging or sending a > notification. > > This leads to an issue: > > * Ordinary actions use a function that the programmer always remembers. > * Important actions require a separate function, which the programmer > might forget. Let's assume we want to support this scenario; we could: a) Throw away all automatic resource management, and make it the user's responsibility to arrange for additional fibers to be cancelled when their "parent" is cancelled b) Create unmanaged fibers by default, but provide a simple mechanism to "attach" to a child/parent c) Provide automatic cleanup by default, but a simple mechanism to "disown" a child/parent (similar to Unix processes) d) Provide two separate-but-equal primitives for spawning coroutines, "run as child", and "run as top-level" Option (a) feels rather unappealing; it also implies that no "parent" relationship is available for things like context data. I think you agree that top-level fibers would be the less common case, so (b) seems awkward as well. Option (c) might look like this: async {     $child = asyncRun foo();     $bgTask = asyncRun bar();     $bgTask->detach(); } // foo() guaranteed to be completed or cancelled, bar() continuing as an independent fiber Or maybe the detach would be inside bar(), e.g. Fiber::getCurrent()->detach() Option (d) might look like this: async {     $child = asyncChild foo();     $bgTask = asyncDetached bar(); } // foo() guaranteed to be completed or cancelled, bar() continuing as an independent fiber (all names and syntax picked for fast illustration, not an exact proposal) -- Rowan Tommins [IMSoP]