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


PHP TimingsHandler::tick方法代码示例

本文整理汇总了PHP中pocketmine\event\TimingsHandler::tick方法的典型用法代码示例。如果您正苦于以下问题:PHP TimingsHandler::tick方法的具体用法?PHP TimingsHandler::tick怎么用?PHP TimingsHandler::tick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\TimingsHandler的用法示例。


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

示例1: tick

 /**
  * Tries to execute a server tick
  */
 private function tick()
 {
     $tickTime = microtime(true);
     if ($tickTime - $this->nextTick < -0.025) {
         //Allow half a tick of diff
         return false;
     }
     Timings::$serverTickTimer->startTiming();
     ++$this->tickCounter;
     $this->checkConsole();
     Timings::$connectionTimer->startTiming();
     $this->network->processInterfaces();
     if ($this->rcon !== null) {
         $this->rcon->check();
     }
     Timings::$connectionTimer->stopTiming();
     Timings::$schedulerTimer->startTiming();
     $this->scheduler->mainThreadHeartbeat($this->tickCounter);
     Timings::$schedulerTimer->stopTiming();
     $this->checkTickUpdates($this->tickCounter, $tickTime);
     foreach ($this->players as $player) {
         $player->checkNetwork();
     }
     if (($this->tickCounter & 0b1111) === 0) {
         $this->titleTick();
         $this->maxTick = 20;
         $this->maxUse = 0;
         if (($this->tickCounter & 0b111111111) === 0) {
             try {
                 $this->getPluginManager()->callEvent($this->queryRegenerateTask = new QueryRegenerateEvent($this, 5));
                 if ($this->queryHandler !== null) {
                     $this->queryHandler->regenerateInfo();
                 }
             } catch (\Exception $e) {
                 if ($this->logger instanceof MainLogger) {
                     $this->logger->logException($e);
                 }
             }
         }
         $this->getNetwork()->updateName();
     }
     if ($this->autoSave and ++$this->autoSaveTicker >= $this->autoSaveTicks) {
         $this->autoSaveTicker = 0;
         $this->doAutoSave();
     }
     if ($this->sendUsageTicker > 0 and --$this->sendUsageTicker === 0) {
         $this->sendUsageTicker = 6000;
         $this->sendUsage(SendUsageTask::TYPE_STATUS);
     }
     if ($this->tickCounter % 100 === 0) {
         foreach ($this->levels as $level) {
             $level->clearCache();
         }
         if ($this->getTicksPerSecondAverage() < 12) {
             $this->logger->warning($this->getLanguage()->translateString("pocketmine.server.tickOverload"));
         }
     }
     if ($this->dispatchSignals and $this->tickCounter % 5 === 0) {
         pcntl_signal_dispatch();
     }
     $this->getMemoryManager()->check();
     Timings::$serverTickTimer->stopTiming();
     $now = microtime(true);
     $tick = min(20, 1 / max(0.001, $now - $tickTime));
     $use = min(1, ($now - $tickTime) / 0.05);
     TimingsHandler::tick($tick <= $this->profilingTickRate);
     if ($this->maxTick > $tick) {
         $this->maxTick = $tick;
     }
     if ($this->maxUse < $use) {
         $this->maxUse = $use;
     }
     array_shift($this->tickAverage);
     $this->tickAverage[] = $tick;
     array_shift($this->useAverage);
     $this->useAverage[] = $use;
     if ($this->nextTick - $tickTime < -1) {
         $this->nextTick = $tickTime;
     } else {
         $this->nextTick += 0.05;
     }
     return true;
 }
开发者ID:ZenaGamingsky,项目名称:PocketBox,代码行数:86,代码来源:Server.php

示例2: tick

 /**
  * Tries to execute a server tick
  */
 private function tick()
 {
     $tickTime = microtime(true);
     if ($tickTime < $this->nextTick) {
         return false;
     }
     Timings::$serverTickTimer->startTiming();
     ++$this->tickCounter;
     $this->checkConsole();
     Timings::$connectionTimer->startTiming();
     $this->network->processInterfaces();
     Timings::$connectionTimer->stopTiming();
     Timings::$schedulerTimer->startTiming();
     $this->scheduler->mainThreadHeartbeat($this->tickCounter);
     Timings::$schedulerTimer->stopTiming();
     $this->checkTickUpdates($this->tickCounter);
     if (($this->tickCounter & 0b1111) === 0) {
         $this->titleTick();
         if ($this->queryHandler !== null and ($this->tickCounter & 0b111111111) === 0) {
             try {
                 $this->queryHandler->regenerateInfo();
             } catch (\Exception $e) {
                 if ($this->logger instanceof MainLogger) {
                     $this->logger->logException($e);
                 }
             }
         }
     }
     Timings::$generationTimer->startTiming();
     try {
         $this->generationManager->process();
     } catch (\Exception $e) {
         if ($this->logger instanceof MainLogger) {
             $this->logger->logException($e);
         }
     }
     Timings::$generationTimer->stopTiming();
     if ($this->tickCounter % 100 === 0) {
         foreach ($this->levels as $level) {
             $level->clearCache();
         }
     }
     Timings::$serverTickTimer->stopTiming();
     TimingsHandler::tick();
     $now = microtime(true);
     array_shift($this->tickAverage);
     $this->tickAverage[] = min(20, 1 / max(0.001, $now - $tickTime));
     array_shift($this->useAverage);
     $this->useAverage[] = min(1, ($now - $tickTime) / 0.05);
     if ($this->nextTick - $tickTime < -1) {
         $this->nextTick = $tickTime;
     }
     $this->nextTick += 0.05;
     return true;
 }
开发者ID:ZenaGamingsky,项目名称:Steadfast2,代码行数:58,代码来源:Server.php


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