File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ You should use the [`Factory`](#factory) to automatically create a new instance.
149149Advanced! If you explicitly need a certain event loop implementation, you can
150150manually instantiate one of the following classes.
151151Note that you may have to install the required PHP extensions for the respective
152- event loop implementation first or this may result in a fatal error .
152+ event loop implementation first or they will throw a ` BadMethodCallException ` on creation .
153153
154154#### StreamSelectLoop
155155
Original file line number Diff line number Diff line change 22
33namespace React \EventLoop ;
44
5+ use BadMethodCallException ;
56use Event ;
67use EventBase ;
78use EventConfig as EventBaseConfig ;
@@ -38,6 +39,10 @@ final class ExtEventLoop implements LoopInterface
3839
3940 public function __construct ()
4041 {
42+ if (!class_exists ('EventBase ' , false )) {
43+ throw new BadMethodCallException ('Cannot create ExtEventLoop, ext-event extension missing ' );
44+ }
45+
4146 $ config = new EventBaseConfig ();
4247 $ config ->requireFeatures (EventBaseConfig::FEATURE_FDS );
4348
Original file line number Diff line number Diff line change 22
33namespace React \EventLoop ;
44
5+ use BadMethodCallException ;
56use libev \EventLoop ;
67use libev \IOEvent ;
78use libev \SignalEvent ;
@@ -36,6 +37,10 @@ final class ExtLibevLoop implements LoopInterface
3637
3738 public function __construct ()
3839 {
40+ if (!class_exists ('libev\EventLoop ' , false )) {
41+ throw new BadMethodCallException ('Cannot create ExtLibevLoop, ext-libev extension missing ' );
42+ }
43+
3944 $ this ->loop = new EventLoop ();
4045 $ this ->futureTickQueue = new FutureTickQueue ();
4146 $ this ->timerEvents = new SplObjectStorage ();
Original file line number Diff line number Diff line change 22
33namespace React \EventLoop ;
44
5+ use BadMethodCallException ;
56use Event ;
67use EventBase ;
78use React \EventLoop \Tick \FutureTickQueue ;
@@ -52,6 +53,10 @@ final class ExtLibeventLoop implements LoopInterface
5253
5354 public function __construct ()
5455 {
56+ if (!function_exists ('event_base_new ' )) {
57+ throw new BadMethodCallException ('Cannot create ExtLibeventLoop, ext-libevent extension missing ' );
58+ }
59+
5560 $ this ->eventBase = event_base_new ();
5661 $ this ->futureTickQueue = new FutureTickQueue ();
5762 $ this ->timerEvents = new SplObjectStorage ();
You can’t perform that action at this time.
0 commit comments