Home  >  Article  >  Backend Development  >  curl_multi_exec 解惑

curl_multi_exec 解惑

WBOY
WBOYOriginal
2016-06-06 20:33:261330browse

<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>

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>

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

Statement:
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