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

PHP gc_enable函数代码示例

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

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



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

示例1: execute

 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('PHPMetrics by Jean-François Lépine <https://twitter.com/Halleck45>');
     $output->writeln('');
     // config
     $configFactory = new ConfigFactory();
     $config = $configFactory->factory($input);
     // files
     if (null === $config->getPath()->getBasePath()) {
         throw new \LogicException('Please provide a path to analyze');
     }
     // files to analyze
     $finder = new Finder($config->getPath()->getExtensions(), $config->getPath()->getExcludedDirs(), $config->getPath()->isFollowSymlinks() ? Finder::FOLLOW_SYMLINKS : null);
     // prepare structures
     $bounds = new Bounds();
     $collection = new \Hal\Component\Result\ResultCollection();
     $aggregatedResults = new \Hal\Component\Result\ResultCollection();
     // execute analyze
     $queueFactory = new QueueFactory($input, $output, $config);
     $queue = $queueFactory->factory($finder, $bounds);
     gc_disable();
     $queue->execute($collection, $aggregatedResults);
     gc_enable();
     $output->writeln('<info>done</info>');
     // evaluation of success
     $evaluator = new Evaluator($collection, $aggregatedResults, $bounds);
     $result = $evaluator->evaluate($config->getFailureCondition());
     // fail if failure-condition is realized
     return $result->isValid() ? 1 : 0;
 }
开发者ID:umair-gujjar,项目名称:PhpMetrics,代码行数:33,代码来源:RunMetricsCommand.php


示例2: __construct

 /**
  * Making the class non-abstract with a protected constructor does a better
  * job of preventing instantiation than just marking the class as abstract.
  *
  * @see start()
  */
 public function __construct(array $configs)
 {
     // Quickly initialize some defaults like usePEAR
     // by adding the $premature flag
     $this->_optionsInit(true);
     $this->setOptions($configs);
     if ($this->opt('logPhpErrors')) {
         set_error_handler(array('self', 'phpErrors'), E_ALL);
     }
     // Check the PHP configuration
     if (!defined('SIGHUP')) {
         trigger_error('PHP is compiled without --enable-pcntl directive', E_USER_ERROR);
     }
     // Check for CLI
     if (php_sapi_name() !== 'cli') {
         trigger_error('You can only create daemon from the command line (CLI-mode)', E_USER_ERROR);
     }
     // Check for POSIX
     if (!function_exists('posix_getpid')) {
         trigger_error('PHP is compiled without --enable-posix directive', E_USER_ERROR);
     }
     // Enable Garbage Collector (PHP >= 5.3)
     if (function_exists('gc_enable')) {
         gc_enable();
     }
     // Initialize & check variables
     if (false === $this->_optionsInit(false)) {
         if (is_object($this->_option) && is_array($this->_option->errors)) {
             foreach ($this->_option->errors as $error) {
                 $this->notice($error);
             }
         }
         trigger_error('Crucial options are not set. Review log:', E_USER_ERROR);
     }
 }
开发者ID:uecode,项目名称:daemon,代码行数:41,代码来源:Daemon.php


示例3: dispatch

 /**
  * Registered callback function for the WordPress Importer
  *
  * Manages the three separate stages of the CSV import process
  */
 function dispatch()
 {
     $this->header();
     if (!empty($_POST['delimiter'])) {
         $this->delimiter = stripslashes(trim($_POST['delimiter']));
     }
     if (!$this->delimiter) {
         $this->delimiter = ',';
     }
     $step = empty($_GET['step']) ? 0 : (int) $_GET['step'];
     switch ($step) {
         case 0:
             $this->greet();
             break;
         case 1:
             check_admin_referer('import-upload');
             if ($this->handle_upload()) {
                 if ($this->id) {
                     $file = get_attached_file($this->id);
                 } else {
                     $file = ABSPATH . $this->file_url;
                 }
                 add_filter('http_request_timeout', array($this, 'bump_request_timeout'));
                 if (function_exists('gc_enable')) {
                     gc_enable();
                 }
                 @set_time_limit(0);
                 @ob_flush();
                 @flush();
                 $this->import($file);
             }
             break;
     }
     $this->footer();
 }
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:40,代码来源:tax-rates-importer.php


示例4: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $force = (bool) $input->getOption('force');
     $verbose = (bool) $input->getOption('verbose');
     $deployLock = $this->getContainer()->getParameter('kernel.cache_dir') . '/deploy.globallock';
     if (file_exists($deployLock)) {
         if ($verbose) {
             $output->writeln('Aborting, ' . $deployLock . ' file present');
         }
         return;
     }
     $doctrine = $this->getContainer()->get('doctrine');
     if ($force) {
         $packages = $doctrine->getManager()->getConnection()->fetchAll('SELECT id FROM package ORDER BY id ASC');
     } else {
         $packages = $doctrine->getRepository('PackagistWebBundle:Package')->getStalePackagesForDumping();
     }
     $ids = array();
     foreach ($packages as $package) {
         $ids[] = $package['id'];
     }
     $lock = new LockHandler('packagist_package_dumper');
     ini_set('memory_limit', -1);
     gc_enable();
     // another dumper is still active
     if (!$lock->lock()) {
         if ($verbose) {
             $output->writeln('Aborting, another dumper is still active');
         }
         return;
     }
     $result = $this->getContainer()->get('packagist.package_dumper')->dump($ids, $force, $verbose);
     $lock->release();
     return $result ? 0 : 1;
 }
开发者ID:xiaobudongzhang,项目名称:packagist,代码行数:38,代码来源:DumpPackagesCommand.php


示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Use all the memory
     ini_set('memory_limit', '-1');
     gc_enable();
     error_reporting(1);
     error_reporting(E_ALL);
     define('DISCORDPHP_STARTTIME', microtime(true));
     define('BASEDIR', __DIR__);
     define('SOVEREIGN_CONFIG_FILE', realpath('./' . ltrim($input->getOption('configFile'), '/')));
     // Init the container object
     $container = getContainer();
     // Load the bot into the service container
     $container->share('app', Sovereign::class)->withArgument($container);
     try {
         // Init the bot
         $container->get('log')->addInfo('Sovereign is starting up..');
         $bot = $container->get('app');
         // Register the default plugins and services, and boot them.
         $container->addServiceProvider(SystemPluginServiceProvider::class);
     } catch (\Exception $e) {
         $container->get('log')->addError('An error occurred: ' . $e->getMessage());
         die;
     }
     // Launch the bot
     $bot->run();
 }
开发者ID:sovereignbot,项目名称:citadel,代码行数:27,代码来源:StartCommand.php


示例6: __construct

 /**
  * @param String $name   Unique name for the manager
  * @param array  $config Config for the manager
  */
 public function __construct($name, array $config = array())
 {
     gc_enable();
     $this->process = \Multitask\Process\Factory::getInstanceOsBased();
     $this->spawner = new \Multitask\Spawner($this, $this->process);
     $this->workingDirectory = $this->pidFilename = $this->name = $name;
     $this->cache = new \Multitask\Cache();
     if (isset($config['logger']) && $config['logger'] instanceof \Multitask\Log\Base) {
         $this->logger = $config['logger'];
     } else {
         $this->logger = new \Multitask\Log\Dummy();
     }
     Error::setHandler($this->logger);
     Error::setName($name);
     foreach ($config as $key => $value) {
         if (array_key_exists($key, $this->config)) {
             $this->config[$key] = $value;
         }
     }
     if (!$this->config['filePath']) {
         $this->config['filePath'] = __DIR__ . '/Cache/';
     }
     $this->fileHandler = new File($this->config['filePath']);
     if ($this->config['timeLimit'] !== false) {
         set_time_limit($this->config['timeLimit']);
     }
     if ($this->config['memoryLimit'] !== false) {
         ini_set('memory_limit', $this->config['memoryLimit']);
     }
 }
开发者ID:fhjbalfoort,项目名称:multitask,代码行数:34,代码来源:Manager.php


示例7: processContent

 /**
  * @inheritdoc
  * @throws ContentProcessorException
  */
 public function processContent(File $asset)
 {
     $path = $asset->getPath();
     try {
         $parser = new \Less_Parser(['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER]);
         $content = $this->assetSource->getContent($asset);
         if (trim($content) === '') {
             return '';
         }
         $tmpFilePath = $this->temporaryFile->createFile($path, $content);
         gc_disable();
         $parser->parseFile($tmpFilePath, '');
         $content = $parser->getCss();
         gc_enable();
         if (trim($content) === '') {
             $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path;
             $this->logger->critical($errorMessage);
             throw new ContentProcessorException(new Phrase($errorMessage));
         }
         return $content;
     } catch (\Exception $e) {
         $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage();
         $this->logger->critical($errorMessage);
         throw new ContentProcessorException(new Phrase($errorMessage));
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:Processor.php


示例8: packagesAction

 /**
  * @Template()
  * @Route("/packages.json", name="packages", defaults={"_format" = "json"})
  */
 public function packagesAction(Request $req)
 {
     // fallback if any of the dumped files exist
     $rootJson = $this->container->getParameter('kernel.root_dir') . '/../web/packages_root.json';
     if (file_exists($rootJson)) {
         return new Response(file_get_contents($rootJson));
     }
     $rootJson = $this->container->getParameter('kernel.root_dir') . '/../web/packages.json';
     if (file_exists($rootJson)) {
         return new Response(file_get_contents($rootJson));
     }
     if ($req->getHost() === 'packagist.org') {
         $this->get('logger')->alert('packages.json is missing and the fallback controller is being hit');
         return new Response('Horrible misconfiguration or the dumper script messed up', 404);
     }
     $em = $this->get('doctrine')->getManager();
     gc_enable();
     $packages = $em->getRepository('Packagist\\WebBundle\\Entity\\Package')->getFullPackages();
     $notifyUrl = $this->generateUrl('track_download', array('name' => 'VND/PKG'));
     $data = array('notify' => str_replace('VND/PKG', '%package%', $notifyUrl), 'packages' => array());
     foreach ($packages as $package) {
         $versions = array();
         foreach ($package->getVersions() as $version) {
             $versions[$version->getVersion()] = $version->toArray();
             $em->detach($version);
         }
         $data['packages'][$package->getName()] = $versions;
         $em->detach($package);
     }
     unset($versions, $package, $packages);
     $response = new Response(json_encode($data), 200);
     $response->setSharedMaxAge(120);
     return $response;
 }
开发者ID:enriquesomolinos,项目名称:packagist,代码行数:38,代码来源:ApiController.php


示例9: packagesAction

 /**
  * @Template()
  * @Route("/packages.json", name="packages", defaults={"_format" = "json"})
  */
 public function packagesAction()
 {
     // fallback if any of the dumped files exist
     $rootJson = $this->container->getParameter('kernel.root_dir') . '/../web/packages_root.json';
     if (file_exists($rootJson)) {
         return new Response(file_get_contents($rootJson));
     }
     $rootJson = $this->container->getParameter('kernel.root_dir') . '/../web/packages.json';
     if (file_exists($rootJson)) {
         return new Response(file_get_contents($rootJson));
     }
     $em = $this->get('doctrine')->getEntityManager();
     gc_enable();
     $packages = $em->getRepository('Packagist\\WebBundle\\Entity\\Package')->getFullPackages();
     $notifyUrl = $this->generateUrl('track_download', array('name' => 'VND/PKG'));
     $data = array('notify' => str_replace('VND/PKG', '%package%', $notifyUrl), 'packages' => array());
     foreach ($packages as $package) {
         $versions = array();
         foreach ($package->getVersions() as $version) {
             $versions[$version->getVersion()] = $version->toArray();
             $em->detach($version);
         }
         $data['packages'][$package->getName()] = $versions;
         $em->detach($package);
     }
     unset($versions, $package, $packages);
     $response = new Response(json_encode($data), 200);
     $response->setSharedMaxAge(120);
     return $response;
 }
开发者ID:ronnylt,项目名称:packagist,代码行数:34,代码来源:ApiController.php


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


示例11: __construct

 /**
  * 
  * @param WebSoccer $websoccer request context.
  * @param DbConnection $db database connection-
  * @param I18n $i18n messages context.
  * @param string $jobId Job ID as defined at jobs.xml.
  * @param $errorOnAlreadyRunning boolean TRUE if error shall occur on init time when an instance of this job is already running.
  */
 function __construct(WebSoccer $websoccer, DbConnection $db, I18n $i18n, $jobId, $errorOnAlreadyRunning = TRUE)
 {
     $this->_websoccer = $websoccer;
     $this->_db = $db;
     $this->_i18n = $i18n;
     $this->_id = $jobId;
     $xmlConfig = $this->getXmlConfig();
     // check if another instance is running (consider timeout of 5 minutes)
     if ($errorOnAlreadyRunning) {
         $initTime = (int) $xmlConfig->attributes()->inittime;
         $now = $websoccer->getNowAsTimestamp();
         $timeoutTime = $now - 5 * 60;
         if ($initTime > $timeoutTime) {
             throw new Exception('Another instance of this job is already running.');
         }
         $this->replaceAttribute('inittime', $now);
     }
     $interval = (int) $xmlConfig->attributes()->interval;
     $this->_interval = $interval * 60;
     ignore_user_abort(TRUE);
     // run possibly forever
     set_time_limit(0);
     // enable garbage collection (in case it is disabled by default)
     gc_enable();
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:33,代码来源:AbstractJob.class.php


示例12: run

 /**
  * мастерский рабочий цикл
  */
 public function run()
 {
     try {
         static::log('starting master (PID ' . posix_getpid() . ')....');
         //задаем приоритет процесса в ОС
         proc_nice($this->priority);
         //включаем сборщик циклических зависимостей
         gc_enable();
         //выполняем функцию приложения до рабочего цикла
         call_user_func([$this->appl, 'baseOnRun']);
         //самый главный цикл
         while (TRUE) {
             if (TRUE === call_user_func([$this->appl, 'baseRun'])) {
                 //прекращаем цикл
                 break;
             }
             //ожидаем заданное время для получения сигнала операционной системы
             $this->sigwait();
             //если сигнал был получен, вызываем связанную с ним функцию
             pcntl_signal_dispatch();
         }
     } catch (\Exception $e) {
         $this->shutdown();
     }
 }
开发者ID:yutas,项目名称:phpdaemon,代码行数:28,代码来源:Master.php


示例13: run

 /**
  * Runtime of Worker process.
  * @return void
  */
 protected function run()
 {
     if (Daemon::$process instanceof Master) {
         Daemon::$process->unregisterSignals();
     }
     EventLoop::init();
     Daemon::$process = $this;
     if (Daemon::$logpointerAsync) {
         Daemon::$logpointerAsync->fd = null;
         Daemon::$logpointerAsync = null;
     }
     class_exists('Timer');
     if (Daemon::$config->autogc->value > 0) {
         gc_enable();
     } else {
         gc_disable();
     }
     $this->prepareSystemEnv();
     $this->registerEventSignals();
     FileSystem::init();
     // re-init
     FileSystem::initEvent();
     Daemon::openLogs();
     $this->fileWatcher = new FileWatcher();
     $this->IPCManager = Daemon::$appResolver->getInstanceByAppName('\\PHPDaemon\\IPCManager\\IPCManager');
     if (!$this->IPCManager) {
         $this->log('cannot instantiate IPCManager');
     }
     EventLoop::$instance->run();
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:34,代码来源:IPC.php


示例14: handle

 public function handle()
 {
     if (Globals::RUNTIME_MODE_CLI !== App::environment(Globals::ENV_RUNTIME_MODE)) {
         throw new ConsoleException("Only run in command line mode");
     }
     //加载Worker并为每个Worker创建一个子进程,然后进入休眠,当接收到信号量时,则执行相应的进程调度操作。
     if (!function_exists("pcntl_signal")) {
         throw new ConsoleException("PHP does not appear to be compiled with the PCNTL extension.This is neccesary for daemonization");
     }
     if (function_exists("gc_enable")) {
         gc_enable();
     }
     $daemon = Daemon::make($_SERVER['argc'], $_SERVER['argv']);
     try {
         /**
          * @var $daemon Daemon
          */
         if (isset($daemon)) {
             $daemon->start();
             sleep(1);
             Console::line("Daemon [" . $daemon->getPID() . "] started.");
         }
     } catch (\Exception $ex) {
         throw new DaemonException($daemon->getName(), $ex->getMessage(), $ex);
     }
 }
开发者ID:sanzhumu,项目名称:xaircraft1.1,代码行数:26,代码来源:DaemonCommand.php


示例15: run

 /**
  * Runtime of Master process
  * @return void
  */
 protected function run()
 {
     Daemon::$process = $this;
     $this->prepareSystemEnv();
     class_exists('Timer');
     // ensure loading this class
     gc_enable();
     /* This line must be commented according to current libevent binding implementation. May be uncommented in future. */
     //$this->eventBase = new \EventBase;
     if ($this->eventBase) {
         $this->registerEventSignals();
     } else {
         $this->registerSignals();
     }
     $this->workers = new Collection();
     $this->collections['workers'] = $this->workers;
     $this->ipcthreads = new Collection();
     $this->collections['ipcthreads'] = $this->ipcthreads;
     Daemon::$appResolver->preload(true);
     $this->callbacks = new StackCallbacks();
     $this->spawnIPCThread();
     $this->spawnWorkers(min(Daemon::$config->startworkers->value, Daemon::$config->maxworkers->value));
     $this->timerCb = function ($event) use(&$cbs) {
         static $c = 0;
         ++$c;
         if ($c > 0xfffff) {
             $c = 1;
         }
         if ($c % 10 == 0) {
             gc_collect_cycles();
         }
         if (!$this->lastMpmActionTs || microtime(true) - $this->lastMpmActionTs > $this->minMpmActionInterval) {
             $this->callMPM();
         }
         if ($event) {
             $event->timeout();
         }
     };
     if ($this->eventBase) {
         // we are using libevent in Master
         Timer::add($this->timerCb, 1000000.0 * Daemon::$config->mpmdelay->value, 'MPM');
         while (!$this->breakMainLoop) {
             $this->callbacks->executeAll($this);
             if (!$this->eventBase->dispatch()) {
                 break;
             }
         }
     } else {
         // we are NOT using libevent in Master
         $lastTimerCall = microtime(true);
         while (!$this->breakMainLoop) {
             $this->callbacks->executeAll($this);
             if (microtime(true) > $lastTimerCall + Daemon::$config->mpmdelay->value) {
                 call_user_func($this->timerCb, null);
                 $lastTimerCall = microtime(true);
             }
             $this->sigwait();
         }
     }
 }
开发者ID:shamahan,项目名称:phpdaemon,代码行数:64,代码来源:Master.php


示例16: huffman_lookup_init

 private static function huffman_lookup_init()
 {
     gc_disable();
     $encodingAccess = [];
     $terminals = [];
     foreach (self::HUFFMAN_CODE as $chr => $bits) {
         $len = self::HUFFMAN_CODE_LENGTHS[$chr];
         for ($bit = 0; $bit < 8; $bit++) {
             $offlen = $len + $bit;
             $next =& $encodingAccess[$bit];
             for ($byte = (int) (($offlen - 1) / 8); $byte > 0; $byte--) {
                 $cur = \str_pad(\decbin($bits >> $byte * 8 - (0x30 - $offlen) % 8 & 0xff), 8, "0", STR_PAD_LEFT);
                 if (isset($next[$cur]) && $next[$cur][0] != $encodingAccess[0]) {
                     $next =& $next[$cur][0];
                 } else {
                     $tmp =& $next;
                     unset($next);
                     $tmp[$cur] = [&$next, null];
                 }
             }
             $key = \str_pad(\decbin($bits & (1 << ($offlen - 1) % 8 + 1) - 1), ($offlen - 1) % 8 + 1, "0", STR_PAD_LEFT);
             $next[$key] = [null, $chr > 0xff ? "" : \chr($chr)];
             if ($offlen % 8) {
                 $terminals[$offlen % 8][] = [$key, &$next];
             } else {
                 $next[$key][0] =& $encodingAccess[0];
             }
         }
     }
     $memoize = [];
     for ($off = 7; $off > 0; $off--) {
         foreach ($terminals[$off] as &$terminal) {
             $key = $terminal[0];
             $next =& $terminal[1];
             if ($next[$key][0] === null) {
                 foreach ($encodingAccess[$off] as $chr => &$cur) {
                     $next[($memoize[$key] ?? ($memoize[$key] = \str_pad($key, 8, "0", STR_PAD_RIGHT))) | $chr] = [&$cur[0], $next[$key][1] != "" ? $next[$key][1] . $cur[1] : ""];
                 }
                 unset($next[$key]);
             }
         }
     }
     $memoize = [];
     for ($off = 7; $off > 0; $off--) {
         foreach ($terminals[$off] as &$terminal) {
             $next =& $terminal[1];
             foreach ($next as $k => $v) {
                 if (\strlen($k) != 1) {
                     $next[$memoize[$k] ?? ($memoize[$k] = \chr(\bindec($k)))] = $v;
                     unset($next[$k]);
                 }
             }
         }
     }
     unset($tmp, $cur, $next, $terminals, $terminal);
     gc_enable();
     gc_collect_cycles();
     return $encodingAccess[0];
 }
开发者ID:amphp,项目名称:aerys,代码行数:59,代码来源:HPack.php


示例17: run

 /**
  * Runtime of Master process
  * @return void
  */
 public function run()
 {
     Daemon::$process = $this;
     $this->prepareSystemEnv();
     class_exists('Timer');
     // ensure loading this class
     gc_enable();
     $this->eventBase = event_base_new();
     $this->registerEventSignals();
     FS::initEvent();
     $this->fileWatcher = new FileWatcher();
     $this->workers = new ThreadCollection();
     $this->collections['workers'] = $this->workers;
     Daemon::$appResolver = (require Daemon::$config->path->value);
     $this->IPCManager = Daemon::$appResolver->getInstanceByAppName('IPCManager');
     Daemon::$appResolver->preload(true);
     $this->callbacks = new SplStack();
     $this->spawnWorkers(min(Daemon::$config->startworkers->value, Daemon::$config->maxworkers->value));
     Timer::add(function ($event) use(&$cbs) {
         $self = Daemon::$process;
         static $c = 0;
         ++$c;
         if ($c > 0xfffff) {
             $c = 1;
         }
         if ($c % 10 == 0) {
             $self->workers->removeTerminated(true);
             gc_collect_cycles();
         } else {
             $self->workers->removeTerminated();
         }
         if (isset(Daemon::$config->mpm->value) && is_callable(Daemon::$config->mpm->value)) {
             call_user_func(Daemon::$config->mpm->value);
         } else {
             // default MPM
             $state = Daemon::getStateOfWorkers($self);
             if ($state) {
                 $n = max(min(Daemon::$config->minspareworkers->value - $state['idle'], Daemon::$config->maxworkers->value - $state['alive']), Daemon::$config->minworkers->value - $state['alive']);
                 if ($n > 0) {
                     Daemon::log('Spawning ' . $n . ' worker(s).');
                     $self->spawnWorkers($n);
                     event_base_loopbreak($self->eventBase);
                 }
                 $n = min($state['idle'] - Daemon::$config->maxspareworkers->value, $state['alive'] - Daemon::$config->minworkers->value);
                 if ($n > 0) {
                     Daemon::log('Stopping ' . $n . ' worker(s).');
                     $self->stopWorkers($n);
                 }
             }
         }
         $event->timeout();
     }, 1000000.0 * Daemon::$config->mpmdelay->value, 'MPM');
     while (!$this->breakMainLoop) {
         while (!$this->callbacks->isEmpty()) {
             call_user_func($this->callbacks->shift(), $this);
         }
         event_base_loop($this->eventBase);
     }
 }
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:63,代码来源:Daemon_MasterThread.php


示例18: iterate

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


示例19: memory_and_gc

/**
 *
 * @ignore
 */
function memory_and_gc($str)
{
    $before = memory_get_usage(true);
    gc_enable();
    $gcs = gc_collect_cycles();
    $after = memory_get_usage(true);
    print "Memory usage at the {$str} : " . convert($before) . ". After GC: " . convert($after) . " and freed {$gcs} variables\n";
}
开发者ID:shpapy,项目名称:pan-configurator,代码行数:12,代码来源:panconfigurator.php


示例20: run

 public function run()
 {
     $this->registerClassLoader();
     gc_enable();
     ini_set("memory_limit", -1);
     global $store;
     $store = [];
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:8,代码来源:AsyncWorker.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP gc_enabled函数代码示例发布时间:2022-05-15
下一篇:
PHP gc_disable函数代码示例发布时间: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