1
0
mirror of https://github.com/danog/amp.git synced 2024-12-14 10:27:58 +01:00
amp/lib/ReactorFactory.php
2014-12-01 19:45:57 -05:00

31 lines
893 B
PHP

<?php
namespace Amp;
class ReactorFactory {
private static $reactor;
/**
* This method is deprecated. New code should use Amp\getReactor() instead.
*/
public static function select(callable $factory = null) {
trigger_error(
'Amp\\ReactorFactory is deprecated and scheduled for removal. ' .
'Please update code to use the Amp\\getReactor() function instead.',
E_USER_DEPRECATED
);
if (self::$reactor) {
return self::$reactor;
} elseif ($factory) {
return self::$reactor = $factory();
} elseif (extension_loaded('uv')) {
return self::$reactor = new UvReactor;
} elseif (extension_loaded('libevent')) {
return self::$reactor = new LibeventReactor;
} else {
return self::$reactor = new NativeReactor;
}
}
}