Io\Poll\Backend::isAvailable

Checks whether the backend is available on the platform

Description

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

Checks whether an Io\Poll\Context can be created with this backend on the current platform.

Parameters

This function has no parameters.

Return Values

Returns true if the backend is available, false otherwise. Io\Poll\Backend::Auto is always available.

Examples

Example #1 Selecting a backend only if it is available

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

$backend = Backend::Kqueue->isAvailable() ? Backend::Kqueue : Backend::Auto;
$context = new Context($backend);

var_dump(Backend::Auto->isAvailable());

The above example will output:

bool(true)

See Also

  • Io\Poll\Backend::getAvailableBackends
  • Io\Poll\Context::__construct