Skip to content

Instantly share code, notes, and snippets.

@bhrdn
Created June 27, 2018 12:45
Show Gist options
  • Save bhrdn/f12fb006885570956a5c46190c4978d6 to your computer and use it in GitHub Desktop.
Save bhrdn/f12fb006885570956a5c46190c4978d6 to your computer and use it in GitHub Desktop.
composer require amphp/amp
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Amp\Delayed;
use Amp\Loop;
use function Amp\asyncCall as u;
list($counter, $delay) = [10, 2000];
u(function () use ($counter, $delay) {
for ($i = 1; $i <= $counter; $i++) {
printf(">> %s" . PHP_EOL, $i);
yield new Delayed($delay);
}
});
Loop::run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment