(PECL yar >= 1.0.0)
Yar_Concurrent_Client::loop — ��������ע��IJ��е���
$callback
[, callable $error_callback
]] ) : boolean�������е��Ѿ�ͨ�� Yar_Concurrent_Client::call()ע��IJ��е���, ���ҵȴ�����.
callback
�������ص�����������, ��ôYar�ڷ��ͳ����е�����֮����������һ������ص�����(��ʱ��û���κ�����), ���õ�ʱ��$callinfo������NULL.
�����ע�Ტ�е��õ�ʱ���ƶ���callback, ��ô�Ǹ�callback�и��ߵ����ȼ�.
error_callback
����ص�����, ���������, ��ôYar�ڳ����ʱ����������ص�����.
Example #1 Yar_Concurrent_Client::loop() example
<?php
function callback($retval, $callinfo) {
if ($callinfo == NULL) {
echo "����, ���е�������ȥ��, ��û���κ�����\n";
} else {
echo "����һ��Զ�̵��õķ���, ���õķ�������", $callinfo["method"],
". ���õ�sequence�� " , $callinfo["sequence"] , "\n";
var_dump($retval);
}
}
function error_callback($type, $error, $callinfo) {
error_log($error);
}
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback");
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters")); // if the callback is not specificed,
// callback in loop will be used
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_PACKAGER => "json"));
//this server accept json packager
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_TIMEOUT=>1));
//custom timeout
Yar_Concurrent_Client::loop("callback", "error_callback"); //send the requests,
//the error_callback is optional
?>
�������̵���������ڣ�
����, ���е�������ȥ��, ��û���κ����� ����һ��Զ�̵��õķ���, ���õķ�������some_method, ���õ�sequence�� 4 string(11) "some_method" ����һ��Զ�̵��õķ���, ���õķ�������some_method, ���õ�sequence�� 1 string(11) "some_method" ����һ��Զ�̵��õķ���, ���õķ�������some_method, ���õ�sequence�� 2 string(11) "some_method" ����һ��Զ�̵��õķ���, ���õķ�������some_method, ���õ�sequence�� 3 string(11) "some_method"