2021-12-12 21:06:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
|
2021-12-12 21:09:19 +01:00
|
|
|
use Amp\Future;
|
2021-12-12 21:06:34 +01:00
|
|
|
use function Amp\async;
|
|
|
|
use function Amp\delay;
|
|
|
|
|
|
|
|
$future1 = async(function () {
|
|
|
|
delay(1);
|
|
|
|
|
2021-12-12 21:09:19 +01:00
|
|
|
print 'c';
|
2021-12-12 21:06:34 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$future2 = async(function () {
|
|
|
|
delay(2);
|
|
|
|
|
2021-12-12 21:09:19 +01:00
|
|
|
print 'd';
|
2021-12-12 21:06:34 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$future3 = async(function () {
|
|
|
|
print 'a';
|
|
|
|
});
|
|
|
|
|
2021-12-12 21:09:19 +01:00
|
|
|
$future4 = async(function () {
|
|
|
|
Future::complete()->await();
|
|
|
|
|
|
|
|
print 'b';
|
|
|
|
});
|
|
|
|
|
2021-12-12 21:06:34 +01:00
|
|
|
$future1->await();
|
|
|
|
$future2->await();
|
|
|
|
$future3->await();
|
|
|
|
|
|
|
|
delay(1);
|
|
|
|
|
2021-12-12 21:09:19 +01:00
|
|
|
print 'e';
|
2021-12-12 21:06:34 +01:00
|
|
|
|
|
|
|
delay(1);
|
|
|
|
|
2021-12-12 21:09:19 +01:00
|
|
|
print 'f';
|