Parallelise http transfers for trip planner tester
[busui.git] / lib / rolling-curl / .svn / text-base / example_groups.php.svn-base
maxious 1 <?php
2 require 'RollingCurl.php';
3 require 'RollingCurlGroup.php';
4
5 class TestCurlRequest extends RollingCurlGroupRequest {
6 public $test_verbose = true;
7
8 function process($output, $info) {
9 echo "Processing " . $this->url . "\n";
10 if ($this->test_verbose)
11 print_r($info);
12
13 parent::process($output, $info);
14 }
15 }
16
17 class TestCurlGroup extends RollingCurlGroup {
18 function process($output, $info, $request) {
19 echo "Group CB: Progress " . $this->name . " (" . ($this->finished_requests + 1) . "/" . $this->num_requests . ")\n";
20 parent::process($output, $info, $request);
21 }
22
23 function finished() {
24 echo "Group CB: Finished" . $this->name . "\n";
25 parent::finished();
26 }
27 }
28
29 $group = new TestCurlGroup("High");
30 $group->add(new TestCurlRequest("www.google.de"));
31 $group->add(new TestCurlRequest("www.yahoo.de"));
32 $group->add(new TestCurlRequest("www.newyorktimes.com"));
33 $reqs[] = $group;
34
35 $group = new TestCurlGroup("Normal");
36 $group->add(new TestCurlRequest("twitter.com"));
37 $group->add(new TestCurlRequest("www.bing.com"));
38 $group->add(new TestCurlRequest("m.facebook.com"));
39 $reqs[] = $group;
40
41 $reqs[] = new TestCurlRequest("www.kernel.org");
42
43 // No callback here, as its done in Request class
44 $rc = new GroupRollingCurl();
45
46 foreach ($reqs as $req)
47 $rc->add($req);
48
49 $rc->execute();