(PHP 8 >= 8.6.0)
The Io\Poll\Event enum lists the conditions an Io\Poll\Context can watch for and report, together with two modifiers that change how they are reported.
A list of cases is passed to Io\Poll\Context::add(), Io\Poll\Watcher::modify() and Io\Poll\Watcher::modifyEvents(), and returned by Io\Poll\Watcher::getWatchedEvents() and Io\Poll\Watcher::getTriggeredEvents().
Io\Poll\Backend::Epoll.
true.
Example #1 Level-triggered and edge-triggered reporting
<?php
use Io\Poll\Context;
use Io\Poll\Event;
use Time\Duration;
[$reader, $writer] = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
// Requires a backend that supports edge triggering, see
// Io\Poll\Backend::supportsEdgeTriggering().
$context = new Context();
$context->add(new StreamPollHandle($reader), [Event::Read, Event::EdgeTriggered]);
fwrite($writer, 'ping');
var_dump(count($context->wait(Duration::fromMilliseconds(10))));
// The data was not read, but the readiness is not reported a second time.
var_dump(count($context->wait(Duration::fromMilliseconds(10))));
fwrite($writer, 'pong');
var_dump(count($context->wait(Duration::fromMilliseconds(10))));Il precedente esempio visualizzerà qualcosa di simile a:
int(1) int(0) int(1)