Created
June 27, 2018 12:45
-
-
Save bhrdn/f12fb006885570956a5c46190c4978d6 to your computer and use it in GitHub Desktop.
composer require amphp/amp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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