Skip to content

Commit

Permalink
Update functions.php
Browse files Browse the repository at this point in the history
Skip delay if timeout is equels 0.0
  • Loading branch information
lav45 authored Feb 20, 2024
1 parent e365d65 commit 6a9774d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ function now(): float
*/
function delay(float $timeout, bool $reference = true, ?Cancellation $cancellation = null): void
{
if ($timeout === 0.0) {
return;
}
$suspension = EventLoop::getSuspension();
$callbackId = EventLoop::delay($timeout, static fn () => $suspension->resume());
$cancellationId = $cancellation?->subscribe(
Expand Down

0 comments on commit 6a9774d

Please sign in to comment.