summaryrefslogtreecommitdiffstats
path: root/vendor/react/event-loop/src/Factory.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:38:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:38:42 +0000
commitc3ca98e1b35123f226c7f4c596b5dee78caa4223 (patch)
tree9b6eb109283da55e7d9064baa9fac795a40264cb /vendor/react/event-loop/src/Factory.php
parentInitial commit. (diff)
downloadicinga-php-thirdparty-c3ca98e1b35123f226c7f4c596b5dee78caa4223.tar.xz
icinga-php-thirdparty-c3ca98e1b35123f226c7f4c596b5dee78caa4223.zip
Adding upstream version 0.11.0.upstream/0.11.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/react/event-loop/src/Factory.php')
-rw-r--r--vendor/react/event-loop/src/Factory.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/vendor/react/event-loop/src/Factory.php b/vendor/react/event-loop/src/Factory.php
new file mode 100644
index 0000000..30bbfd7
--- /dev/null
+++ b/vendor/react/event-loop/src/Factory.php
@@ -0,0 +1,75 @@
+<?php
+
+namespace React\EventLoop;
+
+/**
+ * [Deprecated] The `Factory` class exists as a convenient way to pick the best available event loop implementation.
+ *
+ * @deprecated 1.2.0 See Loop instead.
+ * @see Loop
+ */
+final class Factory
+{
+ /**
+ * [Deprecated] Creates a new event loop instance
+ *
+ * ```php
+ * // deprecated
+ * $loop = React\EventLoop\Factory::create();
+ *
+ * // new
+ * $loop = React\EventLoop\Loop::get();
+ * ```
+ *
+ * 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.
+ *
+ * @deprecated 1.2.0 See Loop::get() instead.
+ * @see Loop::get()
+ *
+ * @return LoopInterface
+ */
+ public static function create()
+ {
+ $loop = self::construct();
+
+ Loop::set($loop);
+
+ return $loop;
+ }
+
+ /**
+ * @internal
+ * @return LoopInterface
+ */
+ private static function construct()
+ {
+ // @codeCoverageIgnoreStart
+ if (\function_exists('uv_loop_new')) {
+ // only use ext-uv on PHP 7
+ return new ExtUvLoop();
+ }
+
+ if (\class_exists('libev\EventLoop', false)) {
+ return new ExtLibevLoop();
+ }
+
+ if (\class_exists('EvLoop', false)) {
+ return new ExtEvLoop();
+ }
+
+ if (\class_exists('EventBase', false)) {
+ return new ExtEventLoop();
+ }
+
+ if (\function_exists('event_base_new') && \PHP_MAJOR_VERSION === 5) {
+ // only use ext-libevent on PHP 5 for now
+ return new ExtLibeventLoop();
+ }
+
+ return new StreamSelectLoop();
+ // @codeCoverageIgnoreEnd
+ }
+}