Skip to content

Commit c9d7d46

Browse files
committed
fix: fix race condition in SystemClock
1 parent 8edc07a commit c9d7d46

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Scheduling/Timing/SystemClock.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ public function sleep(int $seconds): void
3232

3333
public function sleepUntil(DateTimeImmutable $date): void
3434
{
35-
$now = $this->now();
35+
$now = $this->now()->getTimestamp();
36+
$target = $date->getTimestamp();
3637

37-
if ($now >= $date) {
38+
if ($target <= $now) {
3839
return;
3940
}
4041

4142
/** @psalm-suppress UnusedFunctionCall */
42-
\time_sleep_until($date->getTimestamp());
43+
\time_sleep_until($target);
4344
}
4445
}

0 commit comments

Comments
 (0)