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