Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126444 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 B4B381A00BC for ; Tue, 18 Feb 2025 12:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739881282; bh=KZvy9LgngeQNZySgCtnCmUFkj/hkvvtUaboECDgFy8k=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=UqFHVmr5afsJr5BsE84dXrXG+kAJI68LnEw+Jlp6ebpsBMxHB+LVATEwUI2uREwxz W7D7xkNBwUmyZP4qau7dThVnicKGvkb9Fw/4vYm+gcONJsAuP6NfWAnTy+bFtQ9HZX mAVU9omDLF1KuD/g7ELKIhGooBGizNJNTyt/ZD5Ct9AzfuSC7CDAEe/ccFOrJ92J75 ACAYItw93dA6uj2954808IYhwTpzJzCwCLTMTbns0u2yDvrw8GwePmc7Uaji7hspzQ LOdBn7rlY948k8x+CqSWcmazTGjexmug2xFpXBIEXiHKEKz3hCloHbyic/ziD4z3Jc Zj9LO8qAvNHtg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 831B5180048 for ; Tue, 18 Feb 2025 12:21:21 +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,HTML_MESSAGE, 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-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (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 ; Tue, 18 Feb 2025 12:21:21 +0000 (UTC) Received: from phl-compute-13.internal (phl-compute-13.phl.internal [10.202.2.53]) by mailfhigh.stl.internal (Postfix) with ESMTP id CDC732540168; Tue, 18 Feb 2025 07:24:01 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-13.internal (MEProxy); Tue, 18 Feb 2025 07:24:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc: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=1739881441; x= 1739967841; bh=TXyuO4d86VA1uuVpgYhYfMrJomElYh7FF+CJ0+uyPGY=; b=R hUi959fGfCBYi03+nuMd4RVL6447g+DcAr2HoCkcqwxRItSrGE5u8S5fIin0ZsY/ Y5NmS8a9i1wSWYb4RqRKtHCiikydC+fhTfbLptiXqmjjxliGSYPsWwN+Ku+efVUz z2dw+p8nXHwAo5wLx9osFWBZ7SN5jX3Y8Q5fPBid1MxfQIIOe3zVaG7h3WVJftPJ zwR4XD5OU3awtlAryN7z+q44JWNyykIM9q4Xs578wTQySK0Ul7io4sBYOaoIMfZB ahiriUnYB6AXmjhvjLfII0aT0XXbFkLAY2fmstHUUkuPJJ7pAU60oz0qpEf5a+G/ 7APFci58U5cZHJ59R3aeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=fm3; t= 1739881441; x=1739967841; bh=TXyuO4d86VA1uuVpgYhYfMrJomElYh7FF+C J0+uyPGY=; b=m1qq62Nvtg/ftxXnWdINIIy9jKzVi36QBA0OZxWJmclQjaEJ7Tr VnZ/APDf7nBCjBg63ahp/Yx4IC8MA0k0RjYnyryUoc7o+MixMtnW2/36t3Y7B73h BsIZLAv6nS3pcRkh5gWOWa2NGgxQpNmdPlLCi+ysUF9o7oNu5tzYc+SJP6XMlLO/ YJ4RIzcVWHFomiYfvbEw3OTg/rwQz0GbS6diO46mk1xkfONxOZVsIpurbRrm+fSc a17kF9/S7bXVmRLkWasXiduOam4GD57+8PmAp7kXF50Y0h/MO2CaYHSa0HPP8ist fXFU4lV/MaDMHbu5/OOEeY5zb/uWZ3xdogw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeiudeftdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggff fhvfevkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhs fdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpeeiue ethedvvdefjefhgfeiheelheehtdfhfeekjefflefgvedvkeduteejjedttdenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtth hlvggurdgtohguvghspdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopegvughmohhnugdrhhhtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepih hnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtphhtthhopegsihhlghgv sehstghrihhpthhfuhhsihhonhdrtghomh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 3FC46780068; Tue, 18 Feb 2025 07:24:01 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 18 Feb 2025 13:23:40 +0100 To: "Edmond Dantes" , Bilge Cc: internals@lists.php.net Message-ID: <67f5fc49-e14c-42f3-83d1-724002562554@app.fastmail.com> In-Reply-To: References: <24becc76-b67f-4805-b33b-cd4f9f6d0b30@scriptfusion.com> <88656d56-7bfc-4966-8fea-4b4ea883f1f1@scriptfusion.com> Subject: Re: [PHP-DEV] PHP True Async Content-Type: multipart/alternative; boundary=fe81219ddb8e4d398098307f098cc606 From: rob@bottled.codes ("Rob Landers") --fe81219ddb8e4d398098307f098cc606 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Feb 17, 2025, at 20:31, Edmond Dantes wrote: > > There should be no perceptible difference between a blocking sleep(= 10) and an async sleep(10), so what backwards compatibility are you refe= rring to? >=20 > For example, the behavior of the code below will not change. The code = will execute sequentially, and context switching will only occur when `r= esume`/`suspend` is called. >=20 > However, when the `Scheduler` is activated, this behavior changes. Now= , calling `sleep()` inside a `Fiber` will lead to a context switch. >=20 > If the activation of the `Scheduler` is implicit, previously written c= ode may not work as the developer expects. >=20 >=20 > =20 > $fiber =3D new Fiber(function (): void { > echo "Start fiber\n"; > sleep(1); > Fiber::suspend("Paused"); > echo "Resume fiber\n"; > }); >=20 > $result =3D $fiber->start(); >=20 > echo "Fiber suspended with: $result\n"; >=20 > sleep(10); >=20 > $fiber->resume(); >=20 > echo "Fiber finished\n"; I think what bilge was trying to point out is that there should be absol= utely no change on existing software with or without the scheduler runni= ng (for software not using fibers). =E2=80=94 Rob --fe81219ddb8e4d398098307f098cc606 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Mon, Feb 17, 2025, at 20:31, Edmond Dantes wrote:
<= /div>
> =0A=0AThere should be no perceptible differ= ence between a blocking sleep(10) and an async sleep(10), so what backwa= rds compatibility are you referring to?

= For example, the behavior of the code below will not change. The code wi= ll execute sequentially, and context switching will only occur when resume/suspend is called.

However, when = the Scheduler is activated, this behavior changes. Now, cal= ling sleep() inside a Fiber will lead to a con= text switch.

If the activation of the Scheduler i= s implicit, previously written code may not work as the developer expect= s.


<?php

$fiber =3D new Fiber(function (): void {
  &nb= sp; echo "Start fiber\n";
    sleep(1= );
    Fiber::suspend("Paused");
&= nbsp;   echo "Resume fiber\n";
});

=
$result =3D $fiber->start();

= echo "Fiber suspended with: $result\n";

sleep(10);

$fiber->resume();
=

echo "Fiber finished\n";
=

I think what bilge was trying to = point out is that there should be absolutely no change on existing softw= are with or without the scheduler running (for software not using fibers= ).

=E2=80=94 Rob
<= /body> --fe81219ddb8e4d398098307f098cc606--