• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP uv_default_loop函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中uv_default_loop函数的典型用法代码示例。如果您正苦于以下问题:PHP uv_default_loop函数的具体用法?PHP uv_default_loop怎么用?PHP uv_default_loop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了uv_default_loop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     $system = $this;
     //set up the event handler
     set_error_handler(function ($severity, $message, $filePath, $line) use(&$system) {
         $error = new Error($severity, $message, $filePath, $line);
         $system->emit("system.error", $error);
     });
     //set up exception handler
     set_exception_handler(function ($exception) use(&$system) {
         $system->emit("system.exception", $exception);
     });
     //on shutdown, run the event loop
     register_shutdown_function(function () {
         uv_run();
     });
     // start the event loop
     $this->eventLoop = uv_default_loop();
     //set up the core module map
     $modulePrefix = "\\Phastlight\\Module\\";
     $this->moduleMap = array('console' => $modulePrefix . 'Console\\Main', 'process' => $modulePrefix . 'Process\\Main', 'os' => $modulePrefix . 'OS\\Main', 'http' => $modulePrefix . 'HTTP\\Main', 'timer' => $modulePrefix . 'Timer\\Main', 'util' => $modulePrefix . 'Util\\Main', 'fs' => $modulePrefix . 'FileSystem\\Main', 'net' => $modulePrefix . 'NET\\Main', 'child_process' => $modulePrefix . 'ChildProcess\\Main', 'cluster' => $modulePrefix . 'Cluster\\Main');
     $this->modules = array();
 }
开发者ID:phastlight,项目名称:phastlight,代码行数:23,代码来源:System.php


示例2: uv_getaddrinfo

<?php

uv_getaddrinfo(uv_default_loop(), function ($s, $names) {
    var_dump($names);
}, "yahoo.com", NULL, array("ai_family" => UV::AF_UNSPEC));
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:6,代码来源:getaddrinfo.php


示例3: __construct

 /**
  * Create a new uv loop.
  * 
  * @param LoopConfig $config
  */
 public function __construct(LoopConfig $config = null)
 {
     parent::__construct($config);
     //         $this->loop = $loop ?? \uv_loop_new();
     // TODO: Investigate why new uv loops cannot be deleted (segfault) and leak file descriptors...
     $this->loop = \uv_default_loop();
     $this->dispose = new \SplQueue();
     $this->dispose->setIteratorMode(\SplQueue::IT_MODE_FIFO | \SplQueue::IT_MODE_DELETE);
     $this->config->setHostResolver(new Resolver($this));
     $this->config->setFilesystem(new Filesystem($this, $this->config->getFilesystemObserver()));
     if (\defined('PHP_ZTS') && \PHP_ZTS) {
         // TODO: Implement a pool based on uv_queue_work() if ZTS is enabled (unusable: "zend_mm_heap corrupted").
     }
     $this->delayCallback = function ($event) {
         $watcher = $this->timerWatchers[(int) $event] ?? null;
         if ($watcher) {
             $this->info[Watcher::TYPE_DELAY]--;
             unset($this->timerWatchers[(int) $event], $this->watchers[$watcher->id], $this->enable[$watcher->id]);
             if ($watcher->referenced) {
                 $this->watchersReferenced--;
             }
             $watcher->event = null;
             $this->dispose->enqueue($event);
             ($watcher->callback)($watcher->id, $watcher->data);
         }
     };
     $this->repeatCallback = function ($event) {
         $watcher = $this->timerWatchers[(int) $event] ?? null;
         if ($watcher) {
             ($watcher->callback)($watcher->id, $watcher->data);
         }
     };
     $this->streamCallback = function ($event, int $status, int $events) {
         $id = (int) $event;
         if (($events === 0 || $events & \UV::READABLE) && isset($this->readWatchers[$id])) {
             foreach ($this->readWatchers[$id] as $watcher) {
                 ($watcher->callback)($watcher->id, $watcher->stream, $watcher->data);
             }
         }
         if (($events === 0 || $events & \UV::WRITABLE) && isset($this->writeWatchers[$id])) {
             foreach ($this->writeWatchers[$id] as $watcher) {
                 ($watcher->callback)($watcher->id, $watcher->stream, $watcher->data);
             }
         }
     };
     $this->signalCallback = function ($event, int $signo) {
         if (isset($this->signalWatchers[$signo])) {
             foreach ($this->signalWatchers[$signo] as $watcher) {
                 ($watcher->callback)($watcher->id, $watcher->signo, $watcher->data);
             }
         }
     };
 }
开发者ID:koolkode,项目名称:async,代码行数:58,代码来源:UvLoop.php


示例4: uv_fs_readdir

<?php

uv_fs_readdir(uv_default_loop(), ".", 0, function ($result, $da) {
    var_dump($da);
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:6,代码来源:readdir.php


示例5: uv_default_loop

<?php

$loop = uv_default_loop();
$timer = uv_timer_init();
$i = 0;
uv_timer_start($timer, 1000, 1000, function ($stat) use(&$i, $timer, $loop) {
    echo "count: {$i}" . PHP_EOL;
    $i++;
    if ($i > 3) {
        uv_timer_stop($timer);
        uv_unref($timer);
    }
});
uv_run();
echo "finished";
开发者ID:zhanglei,项目名称:php-uv,代码行数:15,代码来源:timer.php


示例6: uv_fs_utime

<?php

uv_fs_utime(uv_default_loop(), __FILE__, time(), time(), function () {
    echo "Finished";
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:6,代码来源:utime.php


示例7: uv_fs_open

<?php

uv_fs_open(uv_default_loop(), __FILE__, UV::O_RDONLY, 0, function ($r) {
    uv_fs_fstat(uv_default_loop(), $r, function ($result, $da) {
        var_dump($da);
    });
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:8,代码来源:fstat.php


示例8: uv_fs_chmod

<?php

uv_fs_chmod(uv_default_loop(), "moe", 0777, function ($result) {
    var_dump($result);
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:6,代码来源:chmod.php


示例9: uv_pipe_init

<?php

$in = uv_pipe_init(uv_default_loop(), true);
echo "HELLO ";
$stdio = array();
$stdio[] = uv_stdio_new($in, UV::CREATE_PIPE | UV::READABLE_PIPE);
$fp = fopen("php://stdout", "w");
$stdio[] = uv_stdio_new($fp, UV::INHERIT_FD | UV::WRITABLE_PIPE);
$flags = 0;
uv_spawn(uv_default_loop(), "php", array('-r', 'var_dump($_ENV);'), $stdio, "/usr/bin/", array("key" => "hello"), function ($process, $stat, $signal) {
    uv_close($process, function () {
    });
}, $flags);
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:14,代码来源:spawn_fd.php


示例10: uv_fs_event_init

<?php

uv_fs_event_init(uv_default_loop(), "/tmp/", function ($rsc, $name, $event, $stat) {
    var_dump($name);
    var_dump($event);
}, 0);
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:7,代码来源:fsevevnt.php


示例11: uv_fs_open

<?php

uv_fs_open(uv_default_loop(), __FILE__, UV::O_RDONLY, 0, function ($read_fd) {
    $stdout = 0;
    uv_fs_sendfile(uv_default_loop(), $stdout, $read_fd, 0, 6, function ($result) {
    });
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:8,代码来源:sendfile.php


示例12: uv_fs_readlink

<?php

uv_fs_readlink(uv_default_loop(), "li", function ($result, $buffer) {
    var_dump($result);
    var_dump($buffer);
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:7,代码来源:readlink.php


示例13: uv_fs_open

<?php

uv_fs_open(uv_default_loop(), "/dev/tty", UV::O_RDONLY, 0, function ($r) {
    $tty = uv_tty_init(uv_default_loop(), $r, 1);
    var_dump(uv_tty_get_winsize($tty, $width, $height));
    var_dump($width, $height);
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:8,代码来源:tty.php


示例14: __construct

 public function __construct()
 {
     $this->eventBase = uv_default_loop();
 }
开发者ID:nangong92t,项目名称:go_src,代码行数:4,代码来源:Libuv.php


示例15: uv_fs_unlink

<?php

uv_fs_unlink(uv_default_loop(), "moe", function ($result) {
    var_dump($result);
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:6,代码来源:unlink.php


示例16: uv_shutdown

                });
            });
            return;
        } else {
            if ($nread == 0) {
                if (uv_last_error() == UV::EOF) {
                    uv_shutdown($client, function ($client) use(&$parsers, &$clients) {
                        uv_close($client, function ($client) use(&$parsers, &$clients) {
                            unset($parsers[(int) $client]);
                            unset($clients[(int) $client]);
                        });
                    });
                    return;
                }
            } else {
                $result = array();
                if (uv_http_parser_execute($parsers[(int) $client], $buffer, $result)) {
                    $response = "HTTP/1.1 200 OK\r\n\r\nHello World";
                    uv_write($client, $response, function ($client) use(&$parsers, &$clients) {
                        uv_close($client, function ($client) use(&$parsers, &$clients) {
                            unset($parsers[(int) $client]);
                            unset($clients[(int) $client]);
                        });
                    });
                }
            }
        }
    });
});
uv_run(uv_default_loop());
开发者ID:zhanglei,项目名称:php-uv,代码行数:30,代码来源:simple_http_server.php


示例17: uv_fs_mkdir

<?php

uv_fs_mkdir(uv_default_loop(), "hoge", 0644, function ($result) {
    var_dump($result);
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:6,代码来源:mkdir.php


示例18: uv_fs_open

<?php

uv_fs_open(uv_default_loop(), "./tmp", UV::O_WRONLY, UV::S_IRWXU | UV::S_IRUSR, function ($r) {
    var_dump($r);
    uv_fs_ftruncate(uv_default_loop(), $r, 0, function () use($r) {
        uv_fs_close(uv_default_loop(), $r, function () {
        });
    });
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:10,代码来源:fs_truncate.php


示例19: stream_socket_server

<?php

$socket = stream_socket_server("tcp://0.0.0.0:9999", $errno, $errstr);
stream_set_blocking($socket, 0);
$poll = uv_poll_init(uv_default_loop(), $socket);
uv_poll_start($poll, UV::READABLE, function ($poll, $stat, $ev, $socket) {
    echo "parent poll:\n";
    var_dump($stat);
    $conn = stream_socket_accept($socket);
    $pp = uv_poll_init(uv_default_loop(), $conn);
    uv_poll_start($pp, UV::WRITABLE, function ($poll, $stat, $ev, $conn) {
        echo "  cb";
        var_dump($stat);
        var_dump($conn);
        uv_poll_stop($poll);
        uv_fs_write(uv_default_loop(), $conn, "Hello World", -1, function ($conn, $nwrite) {
            var_dump($conn);
            fclose($conn);
        });
    });
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:22,代码来源:poll.php


示例20: uv_ares_init_options

<?php

$uv = uv_ares_init_options(uv_default_loop(), array("servers" => array("8.8.8.8"), "port" => 53), null);
ares_gethostbyname($uv, "google.com", AF_INET, function ($name, $addr) {
    var_dump($name);
    var_dump($addr);
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:8,代码来源:gethostbyname.php



注:本文中的uv_default_loop函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP uv_run函数代码示例发布时间:2022-05-23
下一篇:
PHP uuid_create函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap