zookeeper_dispatch
zookeeper_dispatch
Calls callbacks for pending operations
void **zookeeper_dispatch**
The function calls the callbacks passed by operations like or .
zookeeper_dispatch``Zookeeper::get``Zookeeper::exists
Let op: > Since version 0.4.0, this function must be called manually to achieve asynchronous operations. If you want that to be done automatically, you also can declare ticks at the beginning of your program.
After PHP 7.1, you can ignore this function. This extension uses EG(vm_interrupt) to implement async dispatch.
return.void
This method emits PHP warning when callback could not be invoked.
Voorbeeld: example #1
Dispatch callbacks manually.
<?php
$client = new Zookeeper();
$client->connect('localhost:2181');
$client->get('/zookeeper', function() {
echo "Callback was called".PHP_EOL;
});
while(true) {
sleep(1);
zookeeper_dispatch();
}
?>
Voorbeeld: example #2
Declare ticks.
<?php
declare(ticks=1);
$client = new Zookeeper();
$client->connect('localhost:2181');
$client->get('/zookeeper', function() {
echo "Callback was called".PHP_EOL;
});
while(true) {
sleep(1);
}
?>
Zookeeper::addAuth``Zookeeper::connect``Zookeeper::__construct``Zookeeper::exists``Zookeeper::get``Zookeeper::getChildren``Zookeeper::setWatcher