Home > Backend Development > PHP Tutorial > curl_multi_exec 解惑

curl_multi_exec 解惑

WBOY
Release: 2016-06-06 20:33:26
Original
1394 people have browsed it

<code>do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}
</code>
Copy after login
Copy after login

php 手册上看到这个函数,网上查资料说这样写为了避免CPU过高。但是不明白为什么这样写。第一次执行curl_muti_exec 已经把所有的句柄给执行,为什么还要再执行一次

回复内容:

<code>do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}
</code>
Copy after login
Copy after login

php 手册上看到这个函数,网上查资料说这样写为了避免CPU过高。但是不明白为什么这样写。第一次执行curl_muti_exec 已经把所有的句柄给执行,为什么还要再执行一次

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template