Skip to content

Commit

Permalink
Discourage libevent on PHP 7
Browse files Browse the repository at this point in the history
  • Loading branch information
cboden authored and clue committed Oct 13, 2017
1 parent ed4b051 commit bda850f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ class Factory
public static function create()
{
// @codeCoverageIgnoreStart
if (function_exists('event_base_new')) {
return new LibEventLoop();
} elseif (class_exists('libev\EventLoop', false)) {
if (class_exists('libev\EventLoop', false)) {
return new LibEvLoop;
} elseif (class_exists('EventBase', false)) {
return new ExtEventLoop;
} elseif (function_exists('event_base_new') && PHP_VERSION_ID < 70000) {
// only use ext-libevent on PHP < 7 for now
return new LibEventLoop();
}

return new StreamSelectLoop();
Expand Down
4 changes: 4 additions & 0 deletions src/LibEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class LibEventLoop implements LoopInterface

public function __construct()
{
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
trigger_error('The libevent extension has not yet been updated for PHP 7, it is recommended you use a different loop', E_USER_WARNING);
}

$this->eventBase = event_base_new();
$this->futureTickQueue = new FutureTickQueue();
$this->timerEvents = new SplObjectStorage();
Expand Down

0 comments on commit bda850f

Please sign in to comment.