當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。