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

PHP event_base_loopexit函数代码示例

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

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



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

示例1: httpGet

function httpGet($host, $base_fd)
{
    global $index;
    $fd = stream_socket_client("{$host}", $errno, $errstr, 3, STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT);
    $index[$fd] = 0;
    $event_fd = event_new();
    event_set($event_fd, $fd, EV_WRITE | EV_PERSIST, function ($fd, $events, $arg) use($host) {
        global $times, $limit, $index;
        if (!$index[$fd]) {
            $index[$fd] = 1;
            $out = "GET / HTTP/1.1\r\n";
            $out .= "Host: {$host}\r\n";
            $out .= "Connection: Close\r\n\r\n";
            fwrite($fd, $out);
        } else {
            $str = fread($fd, 4096);
            echo $str, PHP_EOL;
            if (feof($fd)) {
                fclose($fd);
                $times++;
                echo "done\n";
                if ($times == $limit - 1) {
                    event_base_loopexit($arg[1]);
                }
            }
        }
    }, array($event_fd, $base_fd));
    event_base_set($event_fd, $base_fd);
    event_add($event_fd);
}
开发者ID:CraryPrimitiveMan,项目名称:code-examples,代码行数:30,代码来源:http.php


示例2: shutdown

 /**
  * 关闭服务器程序
  * @return unknown_type
  */
 function shutdown()
 {
     //关闭服务器端
     sw_socket_close($this->server_sock, $this->server_event);
     //关闭事件循环
     event_base_loopexit($this->base_event);
     $this->protocol->onShutdown();
 }
开发者ID:jasonshaw,项目名称:framework-1,代码行数:12,代码来源:EventUDP.php


示例3: print_line

 function print_line($fd, $events, $arg)
 {
     echo "callback fired" . PHP_EOL;
     var_dump($arg[0]->recv());
     $arg[0]->send("got msg " . ZmqController::$msgs);
     if (ZmqController::$msgs++ >= 10) {
         event_base_loopexit($arg[1]);
     }
 }
开发者ID:stonegithubs,项目名称:yaf-lib,代码行数:9,代码来源:Zmq.php


示例4: foo2

function foo2($buf, $arg)
{
    static $i;
    $i++;
    if ($i == 10) {
        event_base_loopexit($arg);
    }
    var_dump($buf);
    var_dump(event_buffer_read($buf, 10));
}
开发者ID:heartshare,项目名称:VagrantForPhp,代码行数:10,代码来源:libevent.php


示例5: destroyResource

 /**
  * Destroy libevent resource if it is opened
  *
  * @return void
  */
 private function destroyResource()
 {
     foreach ($this->events as $event) {
         $this->removeEvent($event);
     }
     if ($this->handle) {
         event_base_loopexit($this->handle, 1);
         event_base_free($this->handle);
         $this->handle = null;
     }
 }
开发者ID:edefimov,项目名称:async-sockets,代码行数:16,代码来源:LeBase.php


示例6: print_line

function print_line($fd, $events, $arg)
{
    static $max_requests = 0;
    $max_requests++;
    if ($max_requests == 10) {
        // exit loop after 10 writes
        event_base_loopexit($arg[1]);
    }
    // print the line
    echo fgets($fd);
}
开发者ID:exakat,项目名称:exakat,代码行数:11,代码来源:Extlibevent.01.php


示例7: shutdown

 /**
  * 关闭服务器程序
  * @return unknown_type
  */
 function shutdown()
 {
     //关闭所有客户端
     foreach ($this->client_sock as $k => $sock) {
         Stream::close($sock, $this->client_event[$k]);
     }
     //关闭服务器端
     Stream::close($this->server_sock, $this->server_event);
     //关闭事件循环
     event_base_loopexit($this->base_event);
     $this->protocol->onShutdown($this);
 }
开发者ID:foolkaka,项目名称:soaphp-framework,代码行数:16,代码来源:EventTCP.php


示例8: print_line

 function print_line($fd, $events, $arg)
 {
     static $msgs = 1;
     echo "CALLBACK FIRED" . PHP_EOL;
     if ($arg[0]->getsockopt(ZMQ::SOCKOPT_EVENTS) & ZMQ::POLL_IN) {
         echo "Got incoming data" . PHP_EOL;
         var_dump($arg[0]->recv());
         $arg[0]->send("Got msg {$msgs}");
         if ($msgs++ >= 10) {
             event_base_loopexit($arg[1]);
         }
     }
 }
开发者ID:ansendu,项目名称:ZLogger,代码行数:13,代码来源:zmq_server.php


示例9: test

 function test()
 {
     $count = 0;
     $listener = new ZLogger\Listener('tcp://127.0.0.1:5555');
     ok($listener);
     $listener->recv(function ($e, $arg) use(&$count) {
         $count++;
         event_base_loopexit($arg[1]);
     });
     $queue = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, "MySock1");
     ok($queue);
     $queue->connect("tcp://127.0.0.1:5555");
     $encoder = new ZLogger\Encoder();
     // Assign socket 1 to the queue, send and receive
     // var_dump($queue->send("hello there!")->recv());
     $text = $encoder(array('msg' => 'text'));
     // $listener->listen();
     #  		$queue->send($text);
     #  		ok( $count );
 }
开发者ID:ansendu,项目名称:ZLogger,代码行数:20,代码来源:ListenerTest.php


示例10: stop

 public function stop()
 {
     // @codeCoverageIgnoreStart
     event_base_loopexit($this->base);
     // @codeCoverageIgnoreEnd
 }
开发者ID:ramiyer,项目名称:react,代码行数:6,代码来源:LibEventLoop.php


示例11: shutdown

 /**
  * @todo description?
  * @param boolean - Hard? If hard, we shouldn't wait for graceful shutdown of the running applications.
  * @return boolean - Ready?
  */
 public function shutdown($hard = FALSE)
 {
     $error = error_get_last();
     if ($error) {
         if ($error['type'] === E_ERROR) {
             Daemon::log('W#' . $this->pid . ' crashed by error \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line']);
         }
     }
     if (Daemon::$config->logevents->value) {
         $this->log('event shutdown(' . ($hard ? 'HARD' : '') . ') invoked.');
     }
     if (Daemon::$config->throwexceptiononshutdown->value) {
         throw new Exception('event shutdown');
     }
     @ob_flush();
     if ($this->terminated === TRUE) {
         if ($hard) {
             exit(0);
         }
         return;
     }
     $this->terminated = TRUE;
     $this->closeSockets();
     $this->setStatus(3);
     if ($hard) {
         exit(0);
     }
     $this->reloadReady = $this->appInstancesReloadReady();
     if ($this->reload === TRUE) {
         $this->reloadReady = $this->reloadReady && microtime(TRUE) > $this->reloadTime;
     }
     if (Daemon::$config->logevents->value) {
         $this->log('reloadReady = ' . Debug::dump($this->reloadReady));
     }
     $n = 0;
     unset(Timer::$list['checkState']);
     Timer::add(function ($event) {
         $self = Daemon::$process;
         $self->reloadReady = $self->appInstancesReloadReady();
         if ($self->reload === TRUE) {
             $self->reloadReady = $self->reloadReady && microtime(TRUE) > $self->reloadTime;
         }
         if (!$self->reloadReady) {
             $event->timeout();
         } else {
             event_base_loopexit($self->eventBase);
         }
     }, 1000000.0, 'checkReloadReady');
     while (!$this->reloadReady) {
         event_base_loop($this->eventBase);
     }
     //FS::waitAllEvents(); // ensure that all I/O events completed before suicide
     posix_kill(posix_getppid(), SIGCHLD);
     // praying to Master
     exit(0);
     // R.I.P.
 }
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:62,代码来源:Daemon_WorkerThread.php


示例12: shutdown

 function shutdown($timeout = -1)
 {
     event_base_loopexit($this->handle, $timeout);
     return $this;
 }
开发者ID:chh,项目名称:eventor,代码行数:5,代码来源:Base.php


示例13: onWriteFailureEvent

 public function onWriteFailureEvent($buf, $arg = NULL)
 {
     if (Daemon::$config->logevents->value) {
         Daemon::log(__METHOD__ . '()');
     }
     if ($this->onWriteFailure !== NULL) {
         call_user_func($this->onWriteFailure, $this);
     }
     event_base_loopexit(Daemon::$process->eventBase);
     $this->closeWrite();
 }
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:11,代码来源:AsyncStream.php


示例14: stop

 function stop()
 {
     event_base_loopexit($this->base);
 }
开发者ID:medehghani,项目名称:alert,代码行数:4,代码来源:LibeventReactor.php


示例15: unloop

 public function unloop()
 {
     event_base_loopexit($this->event_base);
 }
开发者ID:LookForwardPersistence,项目名称:appserver-in-php,代码行数:4,代码来源:LibEventUnbuffered.php


示例16: onFailureEvent

 /**
  * Called when the connection failed
  * @param resource Descriptor
  * @param mixed Attached variable
  * @return void
  */
 public function onFailureEvent($stream, $arg = null)
 {
     $this->close();
     if ($this->finished) {
         return;
     }
     $this->finished = true;
     if ($this->pool) {
         unset($this->pool->list[$this->id]);
     }
     $this->onFinish();
     event_base_loopexit(Daemon::$process->eventBase);
 }
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:19,代码来源:IOStream.php


示例17: stop

 /**
  * {@inheritDoc}
  */
 public function stop()
 {
     if ($this->state !== self::STOPPED) {
         \event_base_loopexit($this->base);
         \event_base_loopexit($this->keepAliveBase);
         $this->state = self::STOPPING;
     } else {
         throw new \LogicException("Cannot stop(); event reactor not currently active");
     }
 }
开发者ID:nimmen,项目名称:amp,代码行数:13,代码来源:LibeventReactor.php


示例18: shutdown

 /**
  * 关闭服务器程序
  * @return unknown_type
  */
 public function shutdown()
 {
     //关闭所有客户端
     foreach ($this->client_sock as $k => $sock) {
         $this->_closeSocket($sock, $this->client_event[$k]);
     }
     //关闭服务器端
     $this->_closeSocket($this->server_sock, $this->server_event);
     //关闭事件循环
     \event_base_loopexit($this->base_event);
     $this->client->onShutdown();
 }
开发者ID:tempbottle,项目名称:zphp,代码行数:16,代码来源:Php.php


示例19: onFailureEvent

 public function onFailureEvent($stream, $arg)
 {
     if (is_int($stream)) {
         $connId = $stream;
     } elseif ($this->directReads) {
         $connId = array_search($stream, Daemon::$worker->pool, TRUE);
     } else {
         $connId = array_search($stream, $this->buf, TRUE);
     }
     if (Daemon::$settings['logevents']) {
         Daemon::log('[WORKER ' . Daemon::$worker->pid . '] event ' . get_class($this) . '::' . __METHOD__ . '(' . $connId . ') invoked.');
     }
     $this->abortRequestsByConnection($connId);
     $this->closeConnection($connId);
     $sess =& $this->sessions[$connId];
     if ($sess) {
         if ($sess->finished) {
             return;
         }
         $sess->finished = TRUE;
         $sess->onFinish();
     }
     event_base_loopexit(Daemon::$worker->eventBase);
 }
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:24,代码来源:asyncServer.class.php


示例20: onWriteFailureEvent

 public function onWriteFailureEvent($buf, $arg = NULL)
 {
     if (Daemon::$settings['logevents']) {
         Daemon::log(__METHOD__ . '()');
     }
     if ($this->onWriteFailure !== NULL) {
         call_user_func($this->onWriteFailure, $this);
     }
     event_base_loopexit(Daemon::$worker->eventBase);
     $this->closeWrite();
 }
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:11,代码来源:asyncStream.class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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