| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Client\Time; |
| 15: | |
| 16: | use Amp\Cancellation; |
| 17: | use Nexus\Clock\Microseconds; |
| 18: | |
| 19: | use function Amp\delay; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | final readonly class EventLoopDelay implements CancellableDelayInterface |
| 25: | { |
| 26: | #[\Override] |
| 27: | public function sleep(float|int $seconds, ?Cancellation $cancellation = null): void |
| 28: | { |
| 29: | if (Microseconds::fromSeconds($seconds) < 1) { |
| 30: | $cancellation?->throwIfRequested(); |
| 31: | |
| 32: | return; |
| 33: | } |
| 34: | |
| 35: | delay($seconds, cancellation: $cancellation); |
| 36: | } |
| 37: | } |
| 38: | |