Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129396 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 D6B091A00C1 for ; Sat, 22 Nov 2025 14:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763822438; bh=25HSwtMzVVHJkVid94WxczsQuLU1SaxbzT9FAv1z1pM=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=COXOeRaF52eG6s4Pd9xKvdeOz0M+ffOaNu23xOnRaqbLkZqxbvpcTdVlto/2Sm7y3 C61V4VT+4YtnGF5gvhHKq5B+BQyrwKBsBz57oyWpByBsXcHC2UQpbb6TpDYFILUuC6 D9RMBSqsrKMMHUQrNqreLJ1KZAVx/JUxpwgH0lXo6IpyS9MvDFVtVb9DqAw9nnvIRe B4XJxKOFzQjkaNekW4+9SUSp3AWpoD++amQfD51ezWzw6j8//HC4KNOlJw801L5lX9 DB/cKe9WxY/dbaxtL8JywdkLgw3qx+JSeF9suo3EbwWJtghSirj1aJAn1uAFz0oF6e skCEtLNMcoUSQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2BED81801EE for ; Sat, 22 Nov 2025 14:40:36 +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_MISSING, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 22 Nov 2025 14:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thomasbley.de; s=s1-ionos; t=1763822426; x=1764427226; i=mails@thomasbley.de; bh=VeoeQTgPKH7NXXW8R11cJX/7uSTGy0X+cFdnDww85w8=; h=X-UI-Sender-Class:Date:From:To:Cc:Message-ID:In-Reply-To: References:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=Uvd17pJUEPQdja9uu9bdhU8JIqBJ9hPqbOs/Y3BgqCY28PbYZ/1V2qiqPUyt1aCU i4FJD4BgHXt8PhkjGbwhNFqcMEXtTX3Xijmlycja10l/ac7VnIZGoMi8sYr33a5iF +mIyi+xHx098cv4PfCfEJTwR6y4eH9NmrQrl2fehnXvTMytghumEScm2e/mvIX5Rk DkXJjVWgFlS9rpiO2TBfU5HEU/hoESWf5XF/BNyIcroOrtqRf5xv1DR6KPLJI1Rho +uNLWNOTVdq/qYDHpoH3OBi96WZYN5GLdSYCiy6cNovAW+6o+jpiKAGL9OT6A+v12 ckcqmwbNMfb8X34qig== X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from open-xchange-core-mw-default-1.open-xchange-core-mw-hazelcast-headless.open-xchange.svc.cluster.local ([10.73.157.130]) by mrelayeu.kundenserver.de (mreue011 [172.19.35.3]) with ESMTPSA (Nemesis) id 1MYvse-1va03W2Kg4-00OSla; Sat, 22 Nov 2025 15:40:26 +0100 Date: Sat, 22 Nov 2025 15:40:26 +0100 (CET) To: Edmond Dantes Cc: internals@lists.php.net Message-ID: <329450798.8037.1763822426377@email.ionos.de> In-Reply-To: References: <383528143.397454.1763760932585@email.ionos.de> <691963327.399484.1763796022993@email.ionos.de> <1402906904.784903.1763811759896@email.ionos.de> <2015208655.784984.1763811978476@email.ionos.de> <980296152.1071.1763813573083@email.ionos.de> <92865666.4510.1763818506332@email.ionos.de> Subject: Re: [PHP-DEV] [VOTE] True Async RFC 1.6 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v8.38.93 X-Originating-Client: open-xchange-appsuite X-Provags-ID: V03:K1:ePV9+Qx/wKi1iugib5RRDI56/WvuqUNimVrzunC2hbw/1aIxiXb BSOfGLnz83h5goUQvWTeZ5O/dNi8A5kzmidNgTvqb4QX7RQlFwJQg3CNiPpS3Xl7rjn2tjn ofvY1pb70e76tus0AytHFg7MxvMPtYE6tOFIbU/75aUjGmDh032Jaa+AZOcxkfsV9cR0lru vyGDsd+ohseuGTHotChWQ== UI-OutboundReport: notjunk:1;M01:P0:yVZIZo6xUZQ=;hked7PHPVvZQZn187tLuPhacF0e wCvf/9n3d0LfOK4DD/6z9C//IL4EBURupWfD9wTL9W6w9VA8J7L+RqQ9RB/mA8Sv4w0VLNTTH uF9h2hSoua/pWb/8XwiYjm9FAfWwMnuwh3uKpqSvivvfnp/LDeoadjvQlKyWj9QfTAqP0+bmm 2P5Ixww/KFQma9g8tCSrxsWdA+vpmRTbUqHP5cGlFrDzURocxph/eFvZ7641PamqkYDfZfxxB 4dpwAY7sJEOJ8Rw6+L20JIHK5i3Bp15RNlq381xg/bKRVEHLjE3W6Zi600XAEAcWAvo84+2ys dyqkDsr7+jSY92h+jHmXU2G9q+L1QZM3QRncorkxAcUs6j49D5scFfLtadg2MN131U8a5Cfc+ cMRDxQzSrF9P2psK00Nm4+dzd2E/+8P/MdRTFeX4OcGV2VIMrMZQBDj3Fg8vHA4n/1zeNRyHg wJwbt8MagODAF+Hss5A1R38r++wbn96ZWpv16BG9D4NQYMEjwxoxx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2oJBEjOHqyHdsupjAFiCGTMDeOtwx7ZX8yPH Rz68+/+F33r1KBZcweKI2RzN9XIpXwXIhlwSKbrnVPAYcdOzQSM8dqQsb/TpeI93ohDVdylBU Wpn0sPkebELnXTzTjgrNno78gV3Z4DUCp004JZ+gb7K0VR5TvHskTOHWlmuyk4kXeKs9M58vj TVAvt1uWAkz0E From: mails@thomasbley.de (Thomas Bley) > Edmond Dantes hat am 22.11.2025 14:55 CET geschrieb= en: >=20 > =20 > > So I guess you want to use spawn() in a similar way as call_user_func()= works. > yes >=20 > > This changes the behavior of file_get_contents() from the outside > No. >=20 > ```php > function file_get_contents(string $filename): string > { > $fh =3D fopen(); >=20 > // It creates an EPOLL event so it can wake us when the data > becomes available. > $event =3D ReactorAPI.create_event_from($fh); > $waker =3D Scheduler.getCurrentWaker(); > // Event Driven logic inside. > $waker.add_event($event, function() use($waker) { > // Wakeup this coroutine > $waker.wake(); > }); >=20 > // suspend current coroutine > // zz..... z..... > Scheduler.suspend(); >=20 > // Continue here after the IO event >=20 > // Now we have date, return > return fread($fh, ....); > } > ``` >=20 > This is pseudocode. You can assume it always works. > If you call `file_get_contents` directly, it behaves the same way. > So it does not matter where `file_get_contents` is called. > Since all PHP code together with TrueAsync runs inside coroutines, > `file_get_contents` will suspend the coroutine in which it was invoked. >=20 > When you call `spawn`, you simply run the function in another > coroutine, not in your own. But `spawn` has no effect on > `file_get_contents`. >=20 > We=E2=80=99re not at risk of DataRace yet :) We don=E2=80=99t have multit= hreading. > And most likely it won=E2=80=99t appear anytime soon. > // Continue here after the IO event From my understanding, the code does not continue if there is no io event? = Will it use default_socket_timeout from php.ini and/or use the timeout spec= ified in the stream context? Can I mix sync IO and async IO in one function? e.g. if the server uses a m= ixed storage of SSDs and HDDs and I only want async io for the SSDs? Best Regards Thomas