Heim  >  Artikel  >  Backend-Entwicklung  >  curl_multi_exec 解惑

curl_multi_exec 解惑

WBOY
WBOYOriginal
2016-06-06 20:33:261331Durchsuche

<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 已经把所有的句柄给执行,为什么还要再执行一次

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn