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


PHP gc_enabled函数代码示例

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


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

示例1: yay_parse

function yay_parse(string $source, Directives $directives = null, BlueContext $blueContext = null) : string
{
    if ($gc = gc_enabled()) {
        gc_disable();
    }
    // important optimization!
    static $globalDirectives = null;
    if (null === $globalDirectives) {
        $globalDirectives = new ArrayObject();
    }
    $directives = $directives ?: new Directives();
    $blueContext = $blueContext ?: new BlueContext();
    $cg = (object) ['ts' => TokenStream::fromSource($source), 'directives' => $directives, 'cycle' => new Cycle($source), 'globalDirectives' => $globalDirectives, 'blueContext' => $blueContext];
    foreach ($cg->globalDirectives as $d) {
        $cg->directives->add($d);
    }
    traverse(midrule(function (TokenStream $ts) use($directives, $blueContext) {
        $token = $ts->current();
        tail_call:
        if (null === $token) {
            return;
        }
        // skip when something looks like a new macro to be parsed
        if ('macro' === (string) $token) {
            return;
        }
        // here we do the 'magic' to match and expand userland macros
        $directives->apply($ts, $token, $blueContext);
        $token = $ts->next();
        goto tail_call;
    }), consume(chain(token(T_STRING, 'macro')->as('declaration'), optional(repeat(rtoken('/^·\\w+$/')))->as('tags'), lookahead(token('{')), commit(chain(braces()->as('pattern'), operator('>>'), braces()->as('expansion')))->as('body'), optional(token(';'))), CONSUME_DO_TRIM)->onCommit(function (Ast $macroAst) use($cg) {
        $scope = Map::fromEmpty();
        $tags = Map::fromValues(array_map('strval', $macroAst->{'tags'}));
        $pattern = new Pattern($macroAst->{'declaration'}->line(), $macroAst->{'body pattern'}, $tags, $scope);
        $expansion = new Expansion($macroAst->{'body expansion'}, $tags, $scope);
        $macro = new Macro($tags, $pattern, $expansion, $cg->cycle);
        $cg->directives->add($macro);
        // allocate the userland macro
        // allocate the userland macro globally if it's declared as global
        if ($macro->tags()->contains('·global')) {
            $cg->globalDirectives[] = $macro;
        }
    }))->parse($cg->ts);
    $expansion = (string) $cg->ts;
    if ($gc) {
        gc_enable();
    }
    return $expansion;
}
开发者ID:lastguest,项目名称:yay,代码行数:49,代码来源:yay_parse.php

示例2: tearDown

 protected function tearDown()
 {
     //Close & unsets
     if (is_object($this->em)) {
         $this->em->getConnection()->close();
         $this->em->close();
     }
     unset($this->em);
     unset($this->container);
     unset($this->kern);
     unset($this->client);
     //Nettoyage des mocks
     //http://kriswallsmith.net/post/18029585104/faster-phpunit
     $refl = new \ReflectionObject($this);
     foreach ($refl->getProperties() as $prop) {
         if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
             $prop->setAccessible(true);
             $prop->setValue($this, null);
         }
     }
     //Nettoyage du garbage
     if (!gc_enabled()) {
         gc_enable();
     }
     gc_collect_cycles();
     //Parent
     parent::tearDown();
 }
开发者ID:Reallymute,项目名称:IRMApplicative,代码行数:28,代码来源:CarmaWebTestCase.php

示例3: __destruct

	/**
	 * Remove items that link back to this before destroying this object
	 */
	public function __destruct()
	{
		if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
		{
			unset($this->feed);
		}
	}
开发者ID:nicola-amatucci,项目名称:fuel-simplepie,代码行数:10,代码来源:item.php

示例4: iterate

 protected function iterate($seconds)
 {
     sleep($seconds);
     if (!gc_enabled()) {
         gc_enable();
     }
     gc_collect_cycles();
 }
开发者ID:Hypnobox,项目名称:daemon,代码行数:8,代码来源:Daemon.php

示例5: __construct

 public function __construct()
 {
     $this->checkPcntl();
     // Enable PHP 5.3 garbage collection
     if (function_exists('gc_enable')) {
         gc_enable();
         $this->gc = gc_enabled();
     }
 }
开发者ID:shaogx,项目名称:easyJob,代码行数:9,代码来源:Command.php

示例6: setUpBeforeClass

 /**
  * {@inheritdoc}
  */
 public static function setUpBeforeClass()
 {
     // enables garbage collector because symfony/phpunit-bridge disables it. see:
     // see: https://github.com/symfony/symfony/pull/13398/files#diff-81bfee6017752d99d3119f4ddb1a09edR1
     // see: https://github.com/symfony/symfony/pull/13398 (feature list)
     if (!gc_enabled()) {
         gc_enable();
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:12,代码来源:SuluTestCase.php

示例7: Initialize

 /**
  * In the constructor we'll simply initialise the earlier two properties,
  * respectivily with an array and the current timestamp.
  */
 public static function Initialize()
 {
     self::$s_pStatistics = new \stdClass();
     self::$s_pStatistics->Memory = 0;
     self::$s_pStatistics->Cycles = 0;
     self::$s_nLastCollect = time();
     if (!gc_enabled()) {
         gc_enable();
     }
 }
开发者ID:xhoogland,项目名称:Monique,代码行数:14,代码来源:Memory.php

示例8: gc

 /**
  * Gc
  */
 private function gc()
 {
     if (gc_enabled()) {
         gc_collect_cycles();
     } else {
         gc_enable();
         gc_collect_cycles();
         gc_disable();
     }
 }
开发者ID:gridguyz,项目名称:zork,代码行数:13,代码来源:AbstractHttpControllerTestCase.php

示例9: onStopConditionCheck

 /**
  * @param  WorkerEvent $event
  * @return void
  */
 public function onStopConditionCheck(WorkerEvent $event)
 {
     // @see http://php.net/manual/en/features.gc.collecting-cycles.php
     if (gc_enabled()) {
         gc_collect_cycles();
     }
     $usage = memory_get_usage();
     if ($this->maxMemory && $usage > $this->maxMemory) {
         $event->exitWorkerLoop();
         $this->state = sprintf("memory threshold of %s exceeded (usage: %s)", $this->humanFormat($this->maxMemory), $this->humanFormat($usage));
     } else {
         $this->state = sprintf('%s memory usage', $this->humanFormat($usage));
     }
 }
开发者ID:jackdpeterson,项目名称:SlmQueue,代码行数:18,代码来源:MaxMemoryStrategy.php

示例10: timeExec

 protected static function timeExec(callable $code, $rounds)
 {
     $gc_enabled = gc_enabled();
     if ($gc_enabled) {
         gc_disable();
     }
     $start = microtime(TRUE);
     for ($i = 0; $i < $rounds; $i++) {
         $code();
     }
     $end = microtime(TRUE);
     if ($gc_enabled) {
         gc_enable();
     }
     return $end - $start;
 }
开发者ID:flaviovs,项目名称:timeit,代码行数:16,代码来源:Timer.php

示例11: check_pcntl

 /**
  * 环境检查
  * @throws Exception
  */
 public function check_pcntl()
 {
     // Make sure PHP has support for pcntl
     if (!function_exists('pcntl_signal')) {
         $message = 'PHP does not appear to be compiled with the PCNTL extension.  This is neccesary for daemonization';
         throw new Exception($message);
     }
     //信号处理
     pcntl_signal(SIGTERM, array(&$this, "signal_handler"));
     pcntl_signal(SIGINT, array(&$this, "signal_handler"));
     pcntl_signal(SIGQUIT, array(&$this, "signal_handler"));
     // Enable PHP 5.3 garbage collection
     if (function_exists('gc_enable')) {
         gc_enable();
         $this->gc_enabled = gc_enabled();
     }
 }
开发者ID:songguang-2010,项目名称:Zebra-Daemon,代码行数:21,代码来源:DaemonSingle.php

示例12: __construct

 public function __construct($socket_url, $protocol_name, $transport_name = 'Socket')
 {
     if (PHP_SAPI !== 'cli') {
         throw new LogicException("Daemonic Application should be run using CLI SAPI");
     }
     if (version_compare("5.3.0", PHP_VERSION, '>')) {
         throw new LogicException("Daemonic Application requires PHP 5.3.0+");
     }
     // Checking for GarbageCollection patch
     if (false === gc_enabled()) {
         gc_enable();
     }
     $transport_class = 'MFS\\AppServer\\Transport\\' . $transport_name;
     $this->setTransport(new $transport_class($socket_url, array($this, 'onRequest')));
     $protocol_class = 'MFS\\AppServer\\' . $protocol_name . '\\Server';
     $this->setProtocol(new $protocol_class());
     $this->log('Initialized Daemonic Handler');
 }
开发者ID:bermi,项目名称:akelos,代码行数:18,代码来源:DaemonicHandler.class.php

示例13: check_pcntl

 public function check_pcntl()
 {
     if (!function_exists('pcntl_signal_dispatch')) {
         // PHP < 5.3 uses ticks to handle signals instead of pcntl_signal_dispatch
         // call sighandler only every 10 ticks
         declare (ticks=1);
     }
     // Make sure PHP has support for pcntl
     if (!function_exists('pcntl_signal')) {
         $message = 'PHP does not appear to be compiled with the PCNTL extension.  This is neccesary for daemonization';
         throw new \Exception($message);
     }
     //信号处理
     \pcntl_signal(SIGTERM, array(__CLASS__, "signal_handler"), false);
     \pcntl_signal(SIGINT, array(__CLASS__, "signal_handler"), false);
     \pcntl_signal(SIGQUIT, array(__CLASS__, "signal_handler"), false);
     // Enable PHP 5.3 garbage collection
     if (\function_exists('gc_enable')) {
         \gc_enable();
         $this->gc_enabled = \gc_enabled();
     }
 }
开发者ID:songguang-2010,项目名称:Zebra-Daemon,代码行数:22,代码来源:Daemon.php

示例14: gc_disable

<?php

gc_disable();
var_dump(gc_enabled());
gc_enable();
var_dump(gc_enabled());
开发者ID:badlamer,项目名称:hhvm,代码行数:6,代码来源:gc_001.php

示例15: __

     echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="blue">' . __('The Memory Limit value is not available from your Server.', 'bulletproof-security') . '</font></strong><br>';
 } else {
     switch ($memoryLimit) {
         case $memoryLimit >= '128':
             echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="green">' . $memoryLimitM . '</font></strong><br>';
             break;
         case $memoryLimit >= '65' && $memoryLimit < '128':
             echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="blue">' . $memoryLimitM . __(' Recommendation: Increase Memory Limit to 128M.', 'bulletproof-security') . '</font></strong><br>';
             break;
         case $memoryLimit > '0' && $memoryLimit <= '64':
             echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="red">' . $memoryLimitM . __(' Recommendation: Increase Memory Limit to 128M.', 'bulletproof-security') . '</font></strong><br>';
             break;
     }
 }
 if (function_exists('gc_enabled') && function_exists('gc_collect_cycles')) {
     if (gc_enabled()) {
         $garbage = 'On | Cycles: ' . gc_collect_cycles();
     } else {
         $garbage = 'Off';
     }
     echo __('Garbage Collector', 'bulletproof-security') . ': <strong>' . $garbage . '</strong><br>';
 }
 echo __('PHP Max Upload Size', 'bulletproof-security') . ': ';
 $upload_max = ini_get('upload_max_filesize');
 echo '<strong>' . $upload_max . '</strong><br>';
 echo __('PHP Max Post Size', 'bulletproof-security') . ': ';
 $post_max = ini_get('post_max_size');
 echo '<strong>' . $post_max . '</strong><br>';
 echo __('PHP Safe Mode', 'bulletproof-security') . ': ';
 if (ini_get('safe_mode') == 1) {
     $text = '<font color="red"><strong>' . __('On', 'bulletproof-security') . '</strong></font>';
开发者ID:konsultanblog,项目名称:tagamon,代码行数:31,代码来源:system-info_1.php


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