Io\Poll\Backend::supportsEdgeTriggering

Checks whether the backend supports edge-triggered events

説明

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.

パラメータ

この関数にはパラメータはありません。

戻り値

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.

例

例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());

上の例の出力は、 たとえば以下のようになります。

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

参考

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