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


PHP SplObjectStorage::count方法代码示例

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


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

示例1: removeHandler

 /**
  * Remove the given log message handler if it is registered.
  * 
  * @param LogHandler $handler
  */
 public function removeHandler(LogHandler $handler)
 {
     if ($this->handlers->contains($handler)) {
         $this->handlers->detach($handler);
         $this->enabled = $this->handlers->count() ? true : false;
     }
 }
开发者ID:koolkode,项目名称:async,代码行数:12,代码来源:Logger.php

示例2: shouldShutDownMessenger

 protected function shouldShutDownMessenger(Messenger $messenger)
 {
     if ($this->callQueue->count() == 0 && $this->pool->count() > $this->options['min_size']) {
         unset($this->coreMessengerMapping[spl_object_hash($messenger)]);
         $this->pool->detach($messenger);
         $messenger->softTerminate();
         return;
     }
     $this->readyPool->enqueue($messenger);
 }
开发者ID:gabidavila,项目名称:reactphp-child-process-pool,代码行数:10,代码来源:CpuCoreCountFlexiblePool.php

示例3: getConnectionByPosition

 /**
  * @param $pos
  *
  * @return null|AbstractSQLConnection
  */
 public function getConnectionByPosition($pos)
 {
     $pos = (int) $pos;
     $this->storage->rewind();
     for ($i = 0; $this->storage->count() > $i; $i++) {
         if ($i === $pos) {
             return $this->storage->current();
         }
         $this->storage->next();
     }
     return null;
 }
开发者ID:chilimatic,项目名称:database-component,代码行数:17,代码来源:MySQLConnectionStorage.php

示例4: offsetExists

 /**
  * @see ArrayAccess::offsetExists()
  */
 public function offsetExists($offset)
 {
     if ($this->container->count()) {
         $result = true;
         /* @var $keyValue \ArrayAccess */
         foreach ($this->container as $keyValue) {
             $result = $result && $keyValue->offsetExists($offset);
         }
         return $result;
     } else {
         return false;
     }
 }
开发者ID:jiangyu7408,项目名称:Statemachine,代码行数:16,代码来源:Composite.php

示例5: getLink

 /**
  * @inheritDoc
  */
 public function getLink(Driver $driver, Query $query)
 {
     if (!$this->idle->isEmpty()) {
         return $this->idle->dequeue();
     }
     if ($this->pool->count() >= $this->params['max_connections']) {
         $this->waiting->enqueue($query);
         return false;
     }
     $link = $driver->connect($this->params, $this->params['username'], $this->params['passwd']);
     $this->pool->attach($link);
     return $link;
 }
开发者ID:repo2,项目名称:query-reactor,代码行数:16,代码来源:PoolingController.php

示例6: pop

 /**
  * @coroutine
  *
  * @return \Generator
  *
  * @resolve \Icicle\Postgres\Connection
  */
 private function pop() : \Generator
 {
     while (null !== $this->awaitable) {
         try {
             (yield $this->awaitable);
             // Prevent simultaneous connection creation.
         } catch (\Throwable $exception) {
             // Ignore failure or cancellation of other operations.
         }
     }
     if ($this->idle->isEmpty()) {
         try {
             if ($this->connections->count() >= $this->getMaxConnections()) {
                 // All possible connections busy, so wait until one becomes available.
                 $this->awaitable = new Delayed();
                 (yield $this->awaitable);
             } else {
                 // Max connection count has not been reached, so open another connection.
                 $this->awaitable = new Coroutine($this->createConnection());
                 $this->addConnection((yield $this->awaitable));
             }
         } finally {
             $this->awaitable = null;
         }
     }
     // Shift a connection off the idle queue.
     return $this->idle->shift();
 }
开发者ID:icicleio,项目名称:postgres,代码行数:35,代码来源:AbstractPool.php

示例7: getVarId

 protected function getVarId(Operand $var)
 {
     if (isset($this->varIds[$var])) {
         return $this->varIds[$var];
     } else {
         return $this->varIds[$var] = $this->varIds->count() + 1;
     }
 }
开发者ID:ircmaxell,项目名称:php-cfg,代码行数:8,代码来源:Printer.php

示例8: withConnection

 public function withConnection($cb)
 {
     // First check idle connections.
     if ($this->available->count() > 0) {
         $connection = $this->available->dequeue();
         $cb($connection);
         return;
     }
     // Check if we have max connections
     if ($this->pool->count() >= $this->maxConnections) {
         $this->waiting->enqueue($cb);
     }
     // Otherwise, create a new connection
     $connection = ConnectionFactory::createConnection();
     $this->pool->attach($connection);
     $cb($connection);
 }
开发者ID:dustingraham,项目名称:react-mysql,代码行数:17,代码来源:ConnectionPool.php

示例9: invoke

 /**
  * @return ResourceObject|mixed
  */
 private function invoke()
 {
     if ($this->requests->count() === 0) {
         return $this->invoker->invoke($this->request);
     }
     $this->requests->attach($this->request);
     return $this->invoker->invokeSync($this->requests);
 }
开发者ID:mackstar,项目名称:spout,代码行数:11,代码来源:Resource.php

示例10: addSitemap

 /**
  * @param \Sitemapper\SitemapInterface $sitemap
  */
 public function addSitemap(SitemapInterface $sitemap)
 {
     $this->boot();
     $this->sitemaps->attach($sitemap);
     $index = $this->sitemaps->count();
     $sitemap->setLocation($this->getLocation($index));
     $this->sitemaps->offsetSet($sitemap, $index);
     $this->indexSitemap->addSitemap($sitemap);
 }
开发者ID:marcelomx,项目名称:sitemapper,代码行数:12,代码来源:Generator.php

示例11: findReturnBlocks

 protected function findReturnBlocks(Block $block, $result = [])
 {
     $toProcess = new \SplObjectStorage();
     $processed = new \SplObjectStorage();
     $results = new \SplObjectStorage();
     $addNull = false;
     $toProcess->attach($block);
     while ($toProcess->count() > 0) {
         foreach ($toProcess as $block) {
             $toProcess->detach($block);
             $processed->attach($block);
             foreach ($block->children as $op) {
                 if ($op instanceof Op\Terminal\Return_) {
                     $results->attach($op);
                     continue 2;
                     // Prevent dead code from executing
                 } elseif ($op instanceof Op\Terminal\Throw_) {
                     // throws are ok
                     continue 2;
                 } elseif ($op instanceof Op\Stmt\Jump) {
                     if (!$processed->contains($op->target)) {
                         $toProcess->attach($op->target);
                     }
                     continue 2;
                 } elseif ($op instanceof Op\Stmt\JumpIf) {
                     if (!$processed->contains($op->if)) {
                         $toProcess->attach($op->if);
                     }
                     if (!$processed->contains($op->else)) {
                         $toProcess->attach($op->else);
                     }
                     continue 2;
                 } elseif ($op instanceof Op\Stmt\Switch_) {
                     foreach ($op->targets as $target) {
                         if (!is_array($target)) {
                             // TODO FIX THIS
                             $target = [$target];
                         }
                         foreach ($target as $t) {
                             if (!$processed->contains($t)) {
                                 $toProcess->attach($t);
                             }
                         }
                     }
                     continue 2;
                 }
             }
             // If we reach here, we have an empty return default block, add it to the result
             $addNull = true;
         }
     }
     $results = iterator_to_array($results);
     if ($addNull) {
         $results[] = null;
     }
     return $results;
 }
开发者ID:ircmaxell,项目名称:tuli,代码行数:57,代码来源:ReturnType.php

示例12: commit

 /**
  * @param null|mixed|array $models (optional)
  */
 public function commit($models = null)
 {
     $pool = $this->manager->getPool();
     /** @var ObjectManager[] $managers */
     $managers = $pool->getIterator();
     if (null === $models) {
         foreach ($managers as $manager) {
             $manager->flush();
         }
         if (!$this->models->count()) {
             return;
         }
         $this->models->rewind();
         while ($this->models->valid()) {
             $model = $this->models->current();
             $class = $this->manager->getClassMetadata(get_class($model));
             $managerName = $class->getManagerReferenceGenerator();
             $ref = call_user_func(array($model, 'get' . ucfirst($managerName)));
             $id = call_user_func(array($ref, 'get' . ucfirst($class->getIdentifierReference($managerName)->referenceField)));
             foreach ($this->models->getInfo() as $managerName) {
                 $this->saveSpecificModel($model, $managerName, $id);
             }
             $this->models->next();
         }
         // clear list
         $this->models = new \SplObjectStorage();
     } else {
         if (!is_array($models)) {
             $models = array($models);
         }
         foreach ($models as $model) {
             $class = $this->manager->getClassMetadata(get_class($model));
             $managerName = $class->getManagerReferenceGenerator();
             $ref = call_user_func(array($model, 'get' . ucfirst($managerName)));
             $pool->getManager($managerName)->flush($ref);
             $id = call_user_func(array($ref, 'get' . ucfirst($class->getIdentifierReference($managerName)->referenceField)));
             foreach ($class->getFieldManagerNames() as $managerName) {
                 $this->saveSpecificModel($model, $managerName, $id);
             }
         }
     }
 }
开发者ID:pokap,项目名称:pool-dbm,代码行数:45,代码来源:UnitOfWork.php

示例13: createRelationsContent

 public function createRelationsContent(ClassMetadataInterface $classMetadata, $object)
 {
     $relationsContent = new \SplObjectStorage();
     foreach ($classMetadata->getRelations() as $relationMetadata) {
         if (null === $relationMetadata->getContent()) {
             continue;
         }
         $relationsContent->attach($relationMetadata, $this->getContent($relationMetadata, $object));
     }
     return $relationsContent->count() === 0 ? null : $relationsContent;
 }
开发者ID:Ticketpark,项目名称:FSCHateoasBundle,代码行数:11,代码来源:ContentFactory.php

示例14: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->running = true;
     while ($this->running) {
         $this->nextTickQueue->tick();
         $this->futureTickQueue->tick();
         $flags = \Ev::RUN_ONCE;
         if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
             $flags |= \Ev::RUN_NOWAIT;
         } elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count()) {
             break;
         }
         $this->loop->run($flags);
     }
 }
开发者ID:domraider,项目名称:rxnet,代码行数:18,代码来源:LibEvLoop.php

示例15: applyTo

 /**
  * Performs the pipeline of callbacks to initial data.
  * It is possible to set an starting value, and to specify if that starting value has to be
  * casted (only has effect if a caster is set).
  *
  * @param  mixed              $initial
  * @param  \Toobo\PipePie\DTO $dto
  * @param  mixed              $cursor
  * @return mixed
  */
 public function applyTo($initial, DTO $dto = null, $cursor = null)
 {
     if ($this->working) {
         throw new LogicException("It is not possible run a Pipeline that is already working.");
     }
     if ($this->pipeline->count() === 0) {
         return $initial;
     }
     $this->DTOs->push($this->init($dto, $initial));
     $carry = $this->initialValue($initial, $cursor);
     while ($this->pipeline->valid()) {
         $carry = $this->run($initial, $carry);
         $this->pipeline->next();
     }
     $this->working = false;
     return $carry;
 }
开发者ID:toobo,项目名称:pipepie,代码行数:27,代码来源:Pipeline.php


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