Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129128 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 E4BCC1A00BC for ; Fri, 7 Nov 2025 09:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762508732; bh=RNjxRb/aBj1qrBcRSrHv5ngLSltxWhs8U+yGSjuJFQ4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ImS0tWGFHGcAUXTYD1JTtB7SvrVl4ur+okmznxfn7o5WjbnbICbUEhBEeabXyt3+s djcf4XU2oFTUaYIptpmJtt9p2Y4I/XWnc0Ti4qJmAZHOnhKV142ETPasTRQ6G3/PLa XpM8upO4yTqKMz1JocIUs4qK7LBk6h0W0jBpkgnXJbYdCZ2WdF2K1BOcJ2ErnRJunk oIPqLsq3cvadIjCfTrGKuUi564pMpcxN1YQPchtjCKyFDb+W9WdbP+FrLZ07JDNZiY 30tUXhkyetiJdijwfySjbUwFY2yu+AqSyJMjQmB8QvcxHi3PI4rKPj2Q3QLNUNENEg IT6M6cZqob8ig== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 91EF5180050 for ; Fri, 7 Nov 2025 09:45:28 +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,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (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 Nov 2025 09:45:28 +0000 (UTC) Received: by mail-vs1-f44.google.com with SMTP id ada2fe7eead31-5dd88eef2f3so208897137.3 for ; Fri, 07 Nov 2025 01:45:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762508722; x=1763113522; 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=RNjxRb/aBj1qrBcRSrHv5ngLSltxWhs8U+yGSjuJFQ4=; b=KRGfHCL2rR7Cptn5ZLK1ipBqgnJ4lMuPok/+u7aGgeR6kg7d/N2XtxTRn4zP+geYK3 ybEb4lIrL3swz1d0wqyxQa71oOLloi4Ov0EU3vKgo2K/TG9tsx105NjJh5doOWjzSWQ4 XyzWHAAzY+rJmJZWZ2zUg/oN87PoITihVJaagcxnYJctPGHk/NU+U8rRB7c4EvUTb214 15JUZIJpdFnD6NtR9H4MSSbGiL85k+kzPQBd7+dKaWjnANwhMXbixRrWT0/AtLQ4lCiP rZ7zaweKOgNk/EOgTfjxeVMjv+kTMO4OFPrjXc7x9dp9/B2NYCPtq8JyyAhQKF5Uj91Y HJ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762508722; x=1763113522; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RNjxRb/aBj1qrBcRSrHv5ngLSltxWhs8U+yGSjuJFQ4=; b=tEAeIZ89bHh7hfFlybSsMRAEGODrnTM7j2Na+zpdR6s9UJ8I5LOTue4udqy4HdtfHl ZiWEHM+gP/PiXW3bwnXwLpbD5w7AiEwddwMGE8T1WqLEvTGDdUIvwFzOJjkvZCGIDSsm cUg96EBUlJcdUrPpsYJ30+xhSbeJhAUEcxlisFTjvESBVGTHX7VuX/s/WeI++wUm1coq 4WPOHadwHmVE8LkH14FwpiHWwwEQB47iQTFIQTq17ew0ryUj5VSnzPzoJp7TfLQCMnY9 SkWhqNh4VjDcKUady2rCeXtXbs+UxLihYHiFAD2px8Q9HKIjRQRV0k+6yxABrdKYhcJD Q+iw== X-Gm-Message-State: AOJu0Yyzb30vQC9uXvW/yuNX8En0NiXgM91tG7nLCHCeiZaY7Vh244AD 0MY4Zbe6EwRZgAGxsQslCFn9jtRj5JdBcTNGkG1I902dPb0U3sDmVtptE+ygkfShyiYm1Q0gsrZ zcbsi0fIysD1QndN8CJKP8MdWi5bgWDQ= X-Gm-Gg: ASbGncvkrax1FcW6hRNVYqxW4P3vwBIc72sgZnepLnOtp0Ca39UDB7aqjwvcoQL2roe VHEW4eC5jDMpjAxB1dQTK3CbTFadWvB5STlHnMLaoDJOol8SjM9PoED6YLVzEKLHYt3d3fdoo3k jgf5pAWOM9NbdjUvPOg1I71qQ0TIIesa+RG7l+M9jjnrtztXstIAtRFSB4NlrkZkFsm2NIenOLZ AxHj9/948EHP/6i4OWU+eqqwy1EeMysp8FCWGpSOPbFWpYV4+ifl/DYxfIRgwJfFEeB2cvEosml ObRYopnQB0akZLfDeQc+g2i2Pw== X-Google-Smtp-Source: AGHT+IGHO8p1mjw//BzMevukCGYJCW1VruLqK/vBJqm7kaLm/0dFcR38ygJJ3tFmT4y+mxcDJVAgS2yuCGzSrqHWl8c= X-Received: by 2002:a05:6102:8347:10b0:5dd:b318:8a6 with SMTP id ada2fe7eead31-5ddb3180fffmr419363137.12.1762508722614; Fri, 07 Nov 2025 01:45:22 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 7 Nov 2025 11:45:10 +0200 X-Gm-Features: AWmQ_blkSHvNnOpXKyyrbdkopEEDThYBnZYviHKcb1Gs6ZH8Zcy6BWIrxfYcIps Message-ID: Subject: Re: [PHP-DEV] Re: PHP True Async RFC Stage 5 To: =?UTF-8?Q?Lu=C3=ADs_Vin=C3=ADcius_Santos_da_Costa_Barros?= Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: edmond.ht@gmail.com (Edmond Dantes) Hello, Lu=C3=ADs. > Maybe keep the base Awaitable internal and expose two userland interfaces= that match the two cases described in the RFC: Yes, that option is possible, but I want to share my current line of thinki= ng: 1. I=E2=80=99d really like to keep the name `Future` for the `Future` class= , which is planned for upcoming RFCs. 2. I have some doubts that the name `Streamable` precisely conveys the intended meaning (example Signals). However, if our colleagues who are native English speakers say it=E2=80=99s a good choice, I have no objection= s. > Questions (self-cancellation) 1. What happens here? Here=E2=80=99s what happens: 1. The coroutine continues running successfully until completion. 2. The code that calls `await()` receives a `CancellationError("Self-cancelled")` exception. Originally, the idea was to throw an exception directly from `cancel()`, but that would require adding an extra `try-catch` block. So I decided to keep it silent instead. > Can a cancelled coroutine suspend? Nothing will happen. When `cancel()` is called, PHP detects that it=E2=80=99s the current corout= ine and only sets the exception as its result. Later, when `suspend()` is invoked, it creates a new waker object that has no exception, so after resuming, no exception occurs. Do you think this case should be additionally described in the RFC? So, that would give developers a better understanding. Sometimes a coroutine doesn=E2=80=99t cancel itself but its own Scope, and the developer should understand that if they cancel a Scope that includes the current coroutine, they need to finish its work properly from within. > Which error does await() throw in this case =E2=80=94 CancellationError o= r RuntimeException? `RuntimeException`, because this exception will override the previous one. There is more logic here than described in the RFC, because there is an =E2=80=9Coverride=E2=80=9D rule. Exceptions of the `CancellationError` class do not override each other. The first cancellation reason is always visible. However, if an unhandled exception of another class occurs, it will replace the `CancellationError`. In other words, the logic follows these rules: 1. The first cancellation reason takes precedence over subsequent ones. 2. Unexpected errors take precedence over `CancellationError`. So, when a developer tries to cancel a coroutine more than once, it has no effect. > It=E2=80=99d be great to clarify that in the docs, since it affects where= people put cleanup, logging, etc. This case should be described in more detail in the RFC. Thank you for noticing it! > Again, thanks for the work, especially on such an important feature for P= HP=E2=80=99s future. Thank you for your excellent feedback, it=E2=80=99s very inspiring. --- Best Regards, Ed