aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/react/event-loop/src/Factory.php
diff options
context:
space:
mode:
authormarvin-borner@live.com2018-04-10 21:50:16 +0200
committermarvin-borner@live.com2018-04-10 21:54:48 +0200
commitfc9401f04a3aca5abb22f87ebc210de8afe11d32 (patch)
treeb0b310f3581764ec3955f4e496a05137a32951c3 /assets/php/vendor/react/event-loop/src/Factory.php
parent286d643180672f20526f3dc3bd19d7b751e2fa97 (diff)
Initial Commit
Diffstat (limited to 'assets/php/vendor/react/event-loop/src/Factory.php')
-rw-r--r--assets/php/vendor/react/event-loop/src/Factory.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/assets/php/vendor/react/event-loop/src/Factory.php b/assets/php/vendor/react/event-loop/src/Factory.php
new file mode 100644
index 0000000..b46fc07
--- /dev/null
+++ b/assets/php/vendor/react/event-loop/src/Factory.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace React\EventLoop;
+
+/**
+ * The `Factory` class exists as a convenient way to pick the best available event loop implementation.
+ */
+final class Factory
+{
+ /**
+ * Creates a new event loop instance
+ *
+ * ```php
+ * $loop = React\EventLoop\Factory::create();
+ * ```
+ *
+ * This method always returns an instance implementing `LoopInterface`,
+ * the actual event loop implementation is an implementation detail.
+ *
+ * This method should usually only be called once at the beginning of the program.
+ *
+ * @return LoopInterface
+ */
+ public static function create()
+ {
+ // @codeCoverageIgnoreStart
+ if (class_exists('libev\EventLoop', false)) {
+ return new ExtLibevLoop();
+ } elseif (class_exists('EvLoop', false)) {
+ return new ExtEvLoop();
+ } 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 ExtLibeventLoop();
+ }
+
+ return new StreamSelectLoop();
+ // @codeCoverageIgnoreEnd
+ }
+}