Io\Poll\Backend::supportsEdgeTriggering

Checks whether the backend supports edge-triggered events

Description

public bool Io\Poll\Backend::supportsEdgeTriggering()

Checks whether Io\Poll\Event::EdgeTriggered can be used with this backend. Only Io\Poll\Backend::Epoll and Io\Poll\Backend::Kqueue support it.

Parameters

This function has no parameters.

Return Values

Returns true if the backend supports edge triggering, false if it does not or if it is not available on the platform. For Io\Poll\Backend::Auto, the result is that of the backend it selects.

Examples

Example #1 Requesting edge triggering only when it is supported

<?php
use Io\Poll\Context;
use Io\Poll\Event;

[$reader, $writer] = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);

$context = new Context();

$events = [Event::Read];
if ($context->getBackend()->supportsEdgeTriggering()) {
    $events[] = Event::EdgeTriggered;
}

$watcher = $context->add(new StreamPollHandle($reader), $events);
var_dump($watcher->getWatchedEvents());

The above example will output something similar to:

array(2) {
  [0]=>
  enum(Io\Poll\Event::Read)
  [1]=>
  enum(Io\Poll\Event::EdgeTriggered)
}

See Also

  • Io\Poll\Event
  • Io\Poll\Context::getBackend