Exemplo n.º 1
0
function hello($n, $test)
{
    $result = array();
    for ($i = 0; $i < 5; $i++) {
        $result[] = $test->hello("{$n}-{$i}");
    }
    (yield Future\all($result));
}
Exemplo n.º 2
0
<?php

require_once "../vendor/autoload.php";
use Hprose\Future;
use Hprose\Swoole\Client;
Future\co(function () {
    $test = new Client("tcp://127.0.0.1:1314");
    $test->fullDuplex = true;
    $start = microtime(true);
    $n = 100;
    $m = 100;
    for ($j = 0; $j < $n; $j++) {
        $results = array();
        for ($i = 0; $i < $m; $i++) {
            $results[] = $test->hello("{$j}-{$i}");
        }
        (yield Future\all($results));
    }
    $total = microtime(true) - $start;
    $average = $total / $n / $m;
    var_dump($total);
    var_dump($average);
});
Exemplo n.º 3
0
function all($array)
{
    return Future\all($array);
}
Exemplo n.º 4
0
<?php

require_once "../vendor/autoload.php";
use Hprose\Future;
Future\all(array(1, Future\value(2), 3))->then(function ($value) {
    var_dump($value);
});
Future\join(1, Future\value(2), 3)->then(function ($value) {
    var_dump($value);
});