2013-08-05 22:05:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Alert;
|
|
|
|
|
|
|
|
class ReactorFactory {
|
|
|
|
|
|
|
|
private $hasExtLibevent;
|
|
|
|
|
2014-02-23 22:26:28 +01:00
|
|
|
public function __construct() {
|
2013-08-05 22:05:08 +02:00
|
|
|
$this->hasExtLibevent = extension_loaded('libevent');
|
|
|
|
}
|
|
|
|
|
2014-02-23 22:26:28 +01:00
|
|
|
public function __invoke() {
|
2013-08-05 22:05:08 +02:00
|
|
|
return $this->select();
|
|
|
|
}
|
|
|
|
|
2014-02-23 22:26:28 +01:00
|
|
|
public function select() {
|
2013-08-05 22:05:08 +02:00
|
|
|
if ($this->hasExtLibevent) {
|
|
|
|
$reactor = new LibeventReactor;
|
|
|
|
} else {
|
|
|
|
$reactor = new NativeReactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $reactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|