1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 17:09:40 +01:00

Merge pull request #32 from async-interop/support

Add Loop::supports to check for optional features
This commit is contained in:
Andrew Carter 2016-05-14 16:59:17 +01:00
commit 95c2f35e60
3 changed files with 37 additions and 0 deletions

View File

@ -210,6 +210,18 @@ final class Loop
self::get()->unreference($eventIdentifier); self::get()->unreference($eventIdentifier);
} }
/**
* Check whether an optional feature is supported by the current event loop
* driver.
*
* @param int $feature Loop::FEATURE_* constant
*
* @return bool
*/
public static function supports($feature) {
return self::get()->supports($feature);
}
/** /**
* Disable construction as this is a static class. * Disable construction as this is a static class.
*/ */

View File

@ -4,6 +4,8 @@ namespace Interop\Async\EventLoop;
interface LoopDriver interface LoopDriver
{ {
const FEATURE_SIGNAL_HANDLING = 0b001;
/** /**
* Start the event loop. * Start the event loop.
* *
@ -135,4 +137,18 @@ interface LoopDriver
* @return void * @return void
*/ */
public function unreference($eventIdentifier); public function unreference($eventIdentifier);
/**
* Check whether an optional features is supported by this implementation
* and system.
*
* Example: If the implementation can handle signals using PCNTL, but the
* PCNTL extension is not available, the feature MUST NOT be marked as
* supported.
*
* @param int $feature FEATURE constant
*
* @return bool
*/
public function supports($feature);
} }

View File

@ -0,0 +1,9 @@
<?php
use Interop\Async\EventLoop;
/**
* Must be thrown if an optional feature is not supported by the current driver
* or system.
*/
class UnsupportedFeatureException extends \RuntimeException { }