Skip to content

Commit 7ce0fc5

Browse files
committed
Explicitly set desired concurrency
1 parent 71814c4 commit 7ce0fc5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/multi_curl_add_curl_from_url_list.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Curl\Curl;
55
use Curl\MultiCurl;
66

7+
$concurrency = 3;
78
$urls = [
89
'https://www.example.com/?' . md5(mt_rand()),
910
'https://www.example.com/?' . md5(mt_rand()),
@@ -14,6 +15,7 @@
1415
];
1516

1617
$multi_curl = new MultiCurl();
18+
$multi_curl->setConcurrency($concurrency);
1719
$multi_curl->complete(function ($instance) use (&$multi_curl, &$urls) {
1820
echo 'complete:' . $instance->url . "\n";
1921

@@ -30,7 +32,6 @@
3032
});
3133

3234
// Queue a few requests.
33-
$concurrency = 3;
3435
for ($i = 0; $i < $concurrency; $i++) {
3536
$next_url = array_shift($urls);
3637
if ($next_url !== null) {

0 commit comments

Comments
 (0)