-class request extends HttpRequest {
- static $counter = 0;
-
- public $id;
- private $pool;
-
- static function init(pool $pool, $url) {
- $r = new request($url);
- $r->pool = $pool;
- $pool->attach($r);
- return $r;
- }
-
- function onFinish() {
- ++self::$counter;
- $this->pool->detach($this);
- $this->pool->push();
+function push($client, $url, &$n) {
+ if ($n-- > 0) {
+ $req = new http\Client\Request("GET", $url);
+ $client->enqueue($req, function($response) use ($client, $req, $url, &$n) {
+ global $count; ++$count;
+ push($client, $url, $n);
+ return true; // dequeue
+ });