Skip to content

Throw BadMethodCallException on manual loop creating when required extension isn't installed #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ You should use the [`Factory`](#factory) to automatically create a new instance.
Advanced! If you explicitly need a certain event loop implementation, you can
manually instantiate one of the following classes.
Note that you may have to install the required PHP extensions for the respective
event loop implementation first or this may result in a fatal error.
event loop implementation first or they will throw a `BadMethodCallException` on creation.

#### StreamSelectLoop

Expand Down
5 changes: 5 additions & 0 deletions src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace React\EventLoop;

use BadMethodCallException;
use Event;
use EventBase;
use EventConfig as EventBaseConfig;
Expand Down Expand Up @@ -38,6 +39,10 @@ final class ExtEventLoop implements LoopInterface

public function __construct()
{
if (!class_exists('EventBase', false)) {
throw new BadMethodCallException('Cannot create ExtEventLoop, ext-event extension missing');
}

$config = new EventBaseConfig();
$config->requireFeatures(EventBaseConfig::FEATURE_FDS);

Expand Down
5 changes: 5 additions & 0 deletions src/ExtLibevLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace React\EventLoop;

use BadMethodCallException;
use libev\EventLoop;
use libev\IOEvent;
use libev\SignalEvent;
Expand Down Expand Up @@ -36,6 +37,10 @@ final class ExtLibevLoop implements LoopInterface

public function __construct()
{
if (!class_exists('libev\EventLoop', false)) {
throw new BadMethodCallException('Cannot create ExtLibevLoop, ext-libev extension missing');
}

$this->loop = new EventLoop();
$this->futureTickQueue = new FutureTickQueue();
$this->timerEvents = new SplObjectStorage();
Expand Down
5 changes: 5 additions & 0 deletions src/ExtLibeventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace React\EventLoop;

use BadMethodCallException;
use Event;
use EventBase;
use React\EventLoop\Tick\FutureTickQueue;
Expand Down Expand Up @@ -52,6 +53,10 @@ final class ExtLibeventLoop implements LoopInterface

public function __construct()
{
if (!function_exists('event_base_new')) {
throw new BadMethodCallException('Cannot create ExtLibeventLoop, ext-libevent extension missing');
}

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

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy