Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128842 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 8515E1A00BC for ; Wed, 15 Oct 2025 07:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1760514799; bh=zmKLH25CDvoBlk+VFmygNd0Y+PEEF7YB8AIAM6dT54A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FWWToEA3sVeFYrAiUX3+OjAfrAAkgHG2P6VoEqXb/buFN4v3+ORMu2/d/KA2ZnJqZ 83FgVtNmi5Zz1XHJTQ9bYcp3aC6GiivMYkJTNDwxEUgTe9ErAcvb4j90wmvwJBifZY erDBssV/5czf95vmUjuUXRll0lD2DL1qfBJS49J+rIVw6j/XFII/JUJgTJPDzgBp4T M3W1pWbvwUKS03YJ4xphSV8Xf++0qsbVqJ6qhEl87F8M0eGgn6WezDqaAb9Hc46KfM 3QuC2e3040R4yehLeaSWUFfkjVp/ua/g0iSjkvnugyiFmhxxpGOwqYGGcOSDAGM2Wu Q7lFmLLnFEmVA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5EFD918003E for ; Wed, 15 Oct 2025 07:53:18 +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_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-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (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 ; Wed, 15 Oct 2025 07:53:18 +0000 (UTC) Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-5523142df73so4123808e0c.1 for ; Wed, 15 Oct 2025 00:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760514792; x=1761119592; 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=BEQJniPDdwB9DFbDLN9N59H1jgKZDu6tdsTDFTUDxck=; b=TiY35niM7ueaEcAjwkXwX6glkVLaUtdOxPJl2ge4oiuVRXYNHgI1dDG6AnA48HrxMB qYdtqIPQwKmx1Inby4l0N5iHPJAYz/bDU4XmqSlFDjUizQx+CANj+WMSPSGBqIdwMJ5x lf6y4uXPxiIIBdb9GH1Sqdf5Qo6JdtsiWbJ3zxDblVK4Qc8pADpZnheDBPFChbtoCxK5 21WI7IE/ZUx5o8TSk7B/BedEUR1qT8APmjXKq0TjHhdWyxu7q3g+4PWsqf2M4Kh0cTY7 GVTGQ8e4/boa/zIClAstzecAeUAQaI9S4kljPYKko9YV6XjE6ZTvaDtxEded3lUoLBqh RskA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760514792; x=1761119592; 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=BEQJniPDdwB9DFbDLN9N59H1jgKZDu6tdsTDFTUDxck=; b=LkYk/4cshzXCoTA6w3OWzP1nO74GCH9plwvx5i/CkYlE7IE4DmUaNNnuWPNZspcfeu TB6Eq+GQT+JrTANGDLgZf34qkjy9DbJRRqu1KUyA2kDwFKgfklerO24yaXyPZB+D7/fc zTQ4hcZhpiz4cyleGEszxeWZEEOTEzgybx1q2DzXuFv8kYrE1V4N9k6wLY5YjIdSgKpS /SvlWDt/2AG7vtCca+ecGB4r5HksWJYnFdk0R/glhZwb+iOa1PCinUTKdyrY0lpZ0PNq 8w1/Mu1VBL2SZCgy5l9VVt3ySugypho5viYP4YrOlbt9RVqBMQip4jJ87EUt5A1vQTk8 VxSg== X-Gm-Message-State: AOJu0Yx6DLdkoXnPPOjgfk/7zegPRQlwoUzUEHI16uV5Ah7CZF8gDlW+ KzBZ2QOIQjz+5WFroJrBvVLRatwEnCe2gKEJ4CpUjVh74EZUz6pe4dcyGkPv+q+bmy6SATULgKG GgkPJenKPM1YQZXPiDAEGSAkGKMCMEMVzqsrTtZA= X-Gm-Gg: ASbGncv2mGZj0w6J8FHuNNiv0NeZACC/H4smGGBEfJxbYfp4L9okFz0GamcPGhCFlJf NskFtBTWg1IIDsIjxNR2UHIZgFUk8YM/DGvu4OZyml4sF5UW46EgCLk6EByfvpg2fNM4zO8D4pP BqTL7bYN7eEViUHEAnw3hT4Q9GOjOBev9Wa6rPFCbh52QNSda5eE3z4dfnQ2JPTwctFiZW0b9jm Xc4ZxTQ8tFKOPTpDPdnEQ2LqDkxdRZajVzEX1TK2HGcFKBPQSikETiQ X-Google-Smtp-Source: AGHT+IF0BJAs731T9iIB9CFYSyrIC1t8H3h/jH5kRcNpYNIw104J3+NB8f/4uNFCBV5dSTXmEEO91rdqYq9dITHY8bY= X-Received: by 2002:a05:6122:318d:b0:54a:9cff:6fef with SMTP id 71dfb90a1353d-554b8aa98acmr9639034e0c.1.1760514792398; Wed, 15 Oct 2025 00:53:12 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 15 Oct 2025 10:53:01 +0300 X-Gm-Features: AS18NWBlclHRoZJDEg9anPde9Yxb1o11N1g-hX6UtX2DI4bRcsjGs54pZcRJV5Q Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 To: Rob Landers 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. > Why doesn=E2=80=99t scope implement Awaitable? Let=E2=80=99s say there=E2=80=99s a programmer named *John* who is writing = a library, and he has a function that calls an external handler. Programmer *Robert* wrote the `externalHandler`. ```php function processData(string $url, callable $externalHandler): void { ... $externalHandler($result); } ``` John knows which contracts are inside processData, but he knows nothing about `$externalHandler`. From the perspective of `processData`, `$externalHandler` acts as a **black box**. If John uses `await()` on that black box, it may lead to an infinite wait. There are two solutions to this problem: 1. Delegate full responsibility for the program=E2=80=99s behavior to *Robert*, meaning to `$externalHandler` 2. Establish a limiting contract Therefore, if a `Scope` needs to be awaited, it can only be done together with a cancellation token. In real-world scenarios, awaiting a `Scope` during normal execution makes no sense, because you have a `cancellation policy`. This means that at any necessary moment you can dispose() the `Scope` and thus interrupt the execution of tasks inside the black box. For the `TaskGroup` pattern, which exists in the third version of the RFC, awaiting is a relatively safe operation, because in this case we assume that the code is written by someone who has direct access to the agreements and bears full responsibility for any errors. So, `Scope` is intended for components where responsibility is shared between different programmers, while `TaskGroup` should be used when working with a clearly defined set of coroutines.