Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128936 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 lists.php.net (Postfix) with ESMTPS id DDE9C1A00BC for ; Thu, 23 Oct 2025 16:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761237876; bh=hFnDHp1U6ss3E1XlizNWhNLtVU7NIeRJOuEvjHu64VA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nMVxWXF/t+Fs3Y8wN5FvN2MPahregfHo1riFPe9tQtecZ1AWeWnv2WURuFsjGckKU VXYg6iY4fKxTu3WNCScGfTFFFVCd9qG9trjT5ZJVO5J7RFRHRmV3+niPODU8G/j2WR CZFdmSX9ZGFNMR+cftwLl6OuJpeZNt88Al5jvBr/FG/9FkXJ9W/EqY03r2BLf8uhu1 8GRuxjZesqq52wDXnxnzsnbDN0XxZd+xcP5tB9ipmtXMedsrsHFe1P49JM+Qx798Cu usz4+Fd5xGUQYJUrkts4Nh54lfYQ1/FguUl9Q+csVBOIbj+awA7GXbKCKk8WjWSXq1 QJmRn+nL3xxvQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8BC9E1804BC for ; Thu, 23 Oct 2025 16:44:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (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 ; Thu, 23 Oct 2025 16:44:32 +0000 (UTC) Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-932bc48197bso483509241.0 for ; Thu, 23 Oct 2025 09:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761237866; x=1761842666; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZfF70v8a+BAXneAvV6dx59iP7PvMIRen8smlWK+VUMQ=; b=WjidKevKzRfZLEIiMs/DuwOvzh8WsMSnCJiRgnKY+FCQLe3zd19VIPaZmUK3r7iXtY P52GGVcWMp23z5lPRKsGcdzeGoM4e0oTJSScXnPEoEK1Gi+FPRCy0nhEz0GoF2Kg7lqj Pbav4y5m974EUXWhGg6PLvASbWiUidVreDENjS2vTehdUvhBWUzoZ3J8VHbN5onGVa1+ 657UwEjzwk76gg3nwkCAK8Zsq3Z4x/xxRNvbdmymg6+iwD+Ud290tVCzitlE+8rYV92v oFAhdwt48mYEiIjGU2h3kIcghSD5y3k9zhkT0s48ZxsPbRRW7qYhi7qYocCKrIrTajYJ PJeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761237866; x=1761842666; h=content-transfer-encoding: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=ZfF70v8a+BAXneAvV6dx59iP7PvMIRen8smlWK+VUMQ=; b=dgBlrOJVNQjc8t5J+Oza0Um1u+m4vkK4UZRIOCwddb4C/pREbLx+9lhp8M1ZjQr0Ub dLFljk8kGLA6F65OetXJ/HNudQ7iFgiRbCgSLYZ7GaP9ZXpmeYl6Z8fzYes27i3fgQUg 8ySuJzx9CGgyLMRcdLoUrcIaGrNd0n9GV/oKNqkLrnpgzOEup3g/859eBZf5P+SOrdwn e+RP02qjbl8v6X8qLZLtzVRSwLAqu3T6CKjm0zmJge5DD44bmv78eLtD7bYH7S5aPmEB U4yzVNnBNhBBbacyfZoRoixkkQXi3/sCXVJ70by9R3n99FeywEZJ+GyMmvuLiWklO+os IM4Q== X-Forwarded-Encrypted: i=1; AJvYcCXlh2GB3it2oTIgTSKYEvkWSqu5h6GrNdQlp/tZW8eDXsmsBzbfsSG6bmkRiT9eesAdC1Wj6sSuKH0=@lists.php.net X-Gm-Message-State: AOJu0YwCCqpOzW9SOLSKrABqbrFQSVJQfMcPuQJD8pUxT0IfyPvHcd6i kw25Phuys6aSFv03hrItrlaWUXoMWvICwCsQPaqUhq2a0+VuXWcSd+R29yGKoaVKUhbwQc+cWMu lYzV2qqYMdey2feW/Q3mcWbm34DJFxlg= X-Gm-Gg: ASbGnctLtlPXRIF3XJLDfJyj+JvUzuazgGu0VkntkOubPhQhmN55XPWT4Upx1wwK0A3 8o4cVYEvuRCuUDeBvQONGSum6Qn1YYgomVWdsl763ZU4M5nh/bXYYW5MoY407aaGgt/AarN6l3h Pp7QHDv33io3Q8foT9KSg0S1bxLdRqG+yvwqU1G1WitzZLgmTp6D7Gttlb+yqfCmjW1mSIaqqJ0 TlUlYbz4xdtOPmKAd8+q+0K17DhR+xhjdqCIvuhdh7czDN29KaQtbELZgywf7VUlhus6WewdJ8g f+qqJD23YtyKr3i2LFYvYg41cP+Rv7uaYbtG X-Google-Smtp-Source: AGHT+IFnG1A6xKnDoPEOSAyJIYI1WNlYSCrfSCrPpc2gilSHdNUmHw6yyxdTA5CpAS+vq+BVCWFKkp2vgQHN744aE6Y= X-Received: by 2002:a05:6102:370b:b0:5d5:f6ae:74b6 with SMTP id ada2fe7eead31-5d7dd62ac9dmr8451891137.42.1761237866329; Thu, 23 Oct 2025 09:44:26 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <0e4e39d6-9cc9-4970-92e0-2463143b4011@app.fastmail.com> <37180d8d-85b4-49a3-a672-334bf4329470@app.fastmail.com> <2f8524a7-dea2-4fbf-933a-c538d3706253@app.fastmail.com> <151800a7-1094-49bc-8e43-c593a74741af@app.fastmail.com> In-Reply-To: Date: Thu, 23 Oct 2025 19:44:14 +0300 X-Gm-Features: AWmQ_bnVIZSDNqW0RaD4PPM3FMzp4OGapkzew58u1WezORP-9Y4C_74in-mZJMw Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 To: John Bafford Cc: Rob Landers , Aleksander Machniak , PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: edmond.ht@gmail.com (Edmond Dantes) Hi > I don't have any specific use-cases in mind. I'm just trying to be forwa= rd-looking here. But what is clear is that some people would like to see as= ync/await in PHP. This RFC would ostensibly be a > step towards that. All I'm trying to do is make sure that it doesn't put = up roadblocks for future enhancements. > The main obstacles to multithreading are: * The state of the PHP virtual machine, as well as how the bytecode is stored (some elements cannot be transferred) * The memory manager * The garbage collector Of course, for a multithreaded version, the scheduler would have to be almost completely rewritten, but this task doesn=E2=80=99t seem as demandin= g as the ones above. As for the RFC itself, it does not impose any additional limitations beyond those already inherent to PHP. If coroutines can be moved between threads, then all variables must be thread-safe. How will that be guaranteed? The context of a `Closure` must also be thread-safe, how will that be ensured? All these questions are outside the scope of this RFC and relate to the implementation of closures. There is another risk here. If PHP introduces async functionality that works within a single thread, users will start writing code with closures, assuming it will work correctly because everything runs in one thread. The RFC does not regulate this at all, and that=E2=80=99s the problem. Developers will begin writing code designed for single-threaded behavior. If multithreading is later introduced, that code will inevitably break. There=E2=80=99s much more that could be added here. The main point is that = the RFC is not designed around a memory model for parallelism, and such a model should not be part of the RFC. If you=E2=80=99re planning such changes for PHP, it would be wise to come u= p with a way to handle them. But to do that, we first need to understand which memory model you=E2=80=99= ll choose. Will it be Actors + SharedState, meaning special kinds of closures, or something else? > Second: it should be emitting either a stream of files, or a stream of ar= rays of files. Returning list|File is not a great pattern. I wasn=E2=80=99t suggesting doing that, I just wanted to show the differenc= e between =E2=80=9Cmultiple values=E2=80=9D and =E2=80=9Ca single value.=E2= =80=9D > That's the first review thread for Swift's Structured Concurrency proposa= l. > The proposal itself is here, along with links to the three pitch and thre= e review threads, and the async/await and actor proposals: Thank you. I will look at it. > Why is the protect function needed, then? If you request cancellation, th= e coroutine is free to ignore the cancellation and run to completion. That'= s what makes it cooperative. Because cancellation interrupts coroutine waiting. If cancellation occurs deep within the runtime while it is writing a buffer to a socket, it means that not all data will be written. That=E2=80= =99s exactly the case where protect is useful. ---- Thanks, Ed.