mirror of
https://github.com/danog/amp.git
synced 2024-12-04 18:38:17 +01:00
Merge pull request #32 from async-interop/support
Add Loop::supports to check for optional features
This commit is contained in:
commit
95c2f35e60
12
src/Loop.php
12
src/Loop.php
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
9
src/UnsupportedFeatureException.php
Normal file
9
src/UnsupportedFeatureException.php
Normal 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 { }
|
Loading…
Reference in New Issue
Block a user