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


PHP uv_run函数代码示例

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


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

 public function listen($port)
 {
     printf("# server listened at {$port}\n");
     uv_tcp_nodelay($this->server, 1);
     uv_tcp_bind($this->server, uv_ip4_addr("0.0.0.0", $port));
     uv_listen($this->server, 511, array($this, "onConnect"));
     uv_run(uv_default_loop());
 }
开发者ID:chobie,项目名称:chatwork-api-client,代码行数:8,代码来源:HttpServer.php

示例3: dispatch

 /**
  * {@inheritdoc}
  */
 protected function dispatch(int $level)
 {
     $this->dispatching = true;
     try {
         if ($this->deferred || $this->enable || $this->running <= $level) {
             \uv_run($this->loop, \UV::RUN_NOWAIT);
         } else {
             \uv_run($this->loop, \UV::RUN_ONCE);
         }
     } finally {
         foreach ($this->dispose as $callback) {
             \uv_close($callback);
         }
         $this->dispatching = false;
     }
 }
开发者ID:koolkode,项目名称:async,代码行数:19,代码来源:UvLoop.php

示例4: uv_fs_open

<?php

uv_fs_open(uv_default_loop(), "./tmp", UV::O_WRONLY | UV::O_CREAT | UV::O_APPEND, UV::S_IRWXU | UV::S_IRUSR, function ($r) {
    var_dump($r);
    uv_fs_write(uv_default_loop(), $r, "hello", 0, function ($a) use($r) {
        var_dump($a);
        var_dump("ok");
        uv_fs_fdatasync(uv_default_loop(), $r, function () {
            echo "fsync finished";
        });
    });
});
uv_run();
开发者ID:zhanglei,项目名称:php-uv,代码行数:13,代码来源:fsw.php

示例5: dispatch

 /**
  * {@inheritdoc}
  */
 protected function dispatch(bool $blocking)
 {
     \uv_run($this->loopHandle, $blocking ? \UV::RUN_ONCE : \UV::RUN_NOWAIT);
 }
开发者ID:mrxotey,项目名称:icicle,代码行数:7,代码来源:UvLoop.php

示例6: tick

 /**
  * {@inheritDoc}
  */
 public function tick($noWait = false)
 {
     if ($this->state) {
         throw new \LogicException("Cannot tick() recursively; event reactor already active");
     }
     $this->state = self::TICKING;
     $noWait = (bool) $noWait;
     $immediates = $this->immediates;
     foreach ($immediates as $watcher) {
         if (!$this->tryImmediate($watcher)) {
             break;
         }
     }
     // Check the conditional again because a manual stop() could've changed the state
     if ($this->state > 0) {
         \uv_run($this->loop, $noWait || $this->immediates ? \UV::RUN_NOWAIT : \UV::RUN_ONCE);
     }
     $this->state = self::STOPPED;
     if ($this->stopException) {
         $e = $this->stopException;
         $this->stopException = null;
         throw $e;
     }
 }
开发者ID:nimmen,项目名称:amp,代码行数:27,代码来源:UvReactor.php

示例7: 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

示例8: listen

 public function listen($port)
 {
     uv_tcp_nodelay($this->server, 1);
     uv_tcp_bind6($this->server, uv_ip6_addr("::1", $port));
     uv_listen($this->server, 511, array($this, "onConnect"));
     uv_run(uv_default_loop());
 }
开发者ID:zhanglei,项目名称:php-uv,代码行数:7,代码来源:http.php

示例9: runOnce

 /**
  * Runs the loop only once
  *
  * @return LoopInterface
  */
 public function runOnce()
 {
     \uv_run($this->loop, \UV::RUN_ONCE);
     return $this;
 }
开发者ID:HugoSantiagoBecerraAdan,项目名称:php-io,代码行数:10,代码来源:Loop.php

示例10: loop

 public function loop()
 {
     uv_run();
 }
开发者ID:nangong92t,项目名称:go_src,代码行数:4,代码来源:Libuv.php


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