php8.5
Home/ Manual/ eio / functions/ eio_poll

eio_poll

PHP function Edit on GitHub ✎

(PECL eio >= 0.0.1dev)

Can be called whenever there are pending requests that need finishing

Description

eio_poll(): int

eio_poll() can be used to implement special event loop. For this eio_nreqs() could be used to test if there are unprocessed requests.

Note

Applicable only when implementing userspace event loop.

Parameters Parameters

Return Values

If any request invocation returns a non-zero value, returns that value. Otherwise, it returns 0.

Examples

eio_poll() example

php
<?php
function res_cb($data, $result) {
    var_dump($data);
    var_dump($result);
}

eio_nop(EIO_PRI_DEFAULT, "res_cb", "1");
eio_nop(EIO_PRI_DEFAULT, "res_cb", "2");
eio_nop(EIO_PRI_DEFAULT, "res_cb", "3");

while (eio_nreqs()) {
    // Some specific IPC or so
    eio_poll();
}
?>

The above example will output something similar to:

output
string(1) "1"
int(0)
string(1) "3"
int(0)
string(1) "2"
int(0)

See Also

Source: reference/eio/functions/eio-poll.xml · from the official PHP manual (php/doc-en)