1
0
mirror of https://github.com/danog/amp.git synced 2024-12-02 09:27:46 +01:00

Add async example

This commit is contained in:
Niklas Keller 2021-12-12 21:06:34 +01:00
parent cb772a5972
commit 1a0869098b

36
examples/async.php Normal file
View File

@ -0,0 +1,36 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
use function Amp\async;
use function Amp\delay;
$future1 = async(function () {
delay(1);
print 'b';
});
$future2 = async(function () {
delay(2);
print 'c';
});
$future3 = async(function () {
delay(0.5);
print 'a';
});
$future1->await();
$future2->await();
$future3->await();
delay(1);
print 'd';
delay(1);
print 'e';