当前位置: 首页>>代码示例>>PHP>>正文


PHP uv_default_loop函数代码示例

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


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


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