diff --git a/examples/benchmark-throughput.php b/examples/benchmark-throughput.php index 7c436eb..45ceff6 100644 --- a/examples/benchmark-throughput.php +++ b/examples/benchmark-throughput.php @@ -38,12 +38,15 @@ $stderr->write('piping from ' . $if . ' to ' . $of . ' (for max ' . $t . ' second(s)) ...'. PHP_EOL); -Loop::delay($t * 1000, [$in, "close"]); +$running = true; +Loop::delay($t * 1000, function () use (&$running) { + $running = false; +}); -Loop::run(function () use ($stderr, $in, $out) { +Loop::run(function () use (&$running, $stderr, $in, $out) { $start = microtime(true); - while (($chunk = yield $in->read()) !== null) { + while ($running && ($chunk = yield $in->read()) !== null) { yield $out->write($chunk); }