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


PHP SplQueue::push方法代码示例

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


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

示例1: writeItem

 /**
  * {@inheritdoc}
  */
 public function writeItem(array $item)
 {
     $this->queue->push($item);
     if (count($this->queue) >= $this->size) {
         $this->flush();
     }
 }
开发者ID:portphp,项目名称:portphp,代码行数:10,代码来源:BatchWriter.php

示例2: add

 /**
  * Добавляем задачу в очередь
  *
  * @param mixed $data данные запроса
  * @param string $correlation id сообщения
  *
  * @return Producer
  */
 public function add($data = null, $correlation = null)
 {
     $Message = $this->_message($data, ['reply_to' => $this->_cbQueue, 'correlation_id' => $correlation ?: String::uuid()]);
     $this->_collerations[$Message->get('correlation_id')] = time();
     $this->_Messages->push($Message);
     return $this;
 }
开发者ID:pdedkov,项目名称:cakephp-rabbit,代码行数:15,代码来源:Producer.php

示例3: solve

 /**
  * Solve missionaries and cannibals problem.
  *
  * @return bool
  */
 public function solve()
 {
     $initialState = new State(3, 3, 0, 0, 'left');
     $initialNode = new Node($initialState, null, null);
     if ($initialNode->state->isGoalState()) {
         $this->displayNodeInfo($initialNode);
         return true;
     }
     $queue = new SplQueue();
     $queue->push($initialNode);
     $explored = [];
     while (true) {
         if ($queue->isEmpty()) {
             return false;
             //nothing found
         }
         $node = $queue->pop();
         $this->displayNodeInfo($node);
         array_push($explored, $node->state);
         if ($node->state->isGoalState()) {
             return true;
         }
         //get all action and states available
         $states = $node->state->getNextStates();
         foreach ($states as $stateNode) {
             if (!$stateNode->state->isValidState()) {
                 continue;
             }
             if (!in_array($stateNode->state, $explored)) {
                 $queue->push($stateNode);
             }
         }
     }
 }
开发者ID:ankitpokhrel,项目名称:MissionariesAndCannibals-PHP,代码行数:39,代码来源:MissionariesAndCannibals.php

示例4: execute

 /**
  * {@inheritdoc}
  */
 public function execute(Immediate $immediate)
 {
     if (!$this->immediates->contains($immediate)) {
         $this->queue->push($immediate);
         $this->immediates->attach($immediate);
     }
 }
开发者ID:Nik-ADA,项目名称:icicle,代码行数:10,代码来源:SharedImmediateManager.php

示例5: push

 /**
  * 压入 middleware 
  *
  * @param  callbale  $callbale 一般为回调函数
  * @return \Lime\Middleware
  */
 public function push($callbale)
 {
     if ($callbale instanceof \Closure) {
         $callbale = $this->bindToThis($callbale);
     }
     $this->queue->push($callbale);
     return $this;
 }
开发者ID:icodechef,项目名称:Lime,代码行数:14,代码来源:Middleware.php

示例6: testProvideQueueAsStartPoint

 /**
  * @covers Gliph\Traversal\DepthFirst::traverse
  */
 public function testProvideQueueAsStartPoint()
 {
     extract($this->v);
     $queue = new \SplQueue();
     $queue->push($a);
     $queue->push($e);
     $this->g->addVertex($a);
     $this->g->addVertex($e);
     DepthFirst::traverse($this->g, new DepthFirstNoOpVisitor(), $queue);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:13,代码来源:DepthFirstTest.php

示例7: testForValidValues

 public function testForValidValues()
 {
     $var = new \SplQueue();
     $var->push(1);
     $var->push(2);
     $var->push(3);
     $data = new VariableWrapper(get_class($var), $var);
     $result = $this->inspector->get($data);
     $this->assertInstanceOf('Ladybug\\Plugin\\Extra\\Type\\CollectionType', $result);
     $this->assertCount(3, $result);
 }
开发者ID:raulfraile,项目名称:ladybug-plugin-extra,代码行数:11,代码来源:SplQueueTest.php

示例8: iterate_queue_with_mode

function iterate_queue_with_mode($mode)
{
    $x = new SplQueue();
    $x->setIteratorMode($mode);
    $x->push(1);
    $x->push(2);
    $x->push(3);
    foreach ($x as $y) {
        var_dump($y);
    }
    var_dump(count($x));
}
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:queue_iteration.php

示例9: send

 /**
  * @coroutine
  *
  * @param string $data
  * @param float|int $timeout
  * @param bool $end
  *
  * @return \Generator
  *
  * @resolve int Number of bytes written to the file.
  *
  * @throws \Icicle\Stream\Exception\UnwritableException
  */
 protected function send(string $data, float $timeout, bool $end = false) : \Generator
 {
     if (!$this->isWritable()) {
         throw new UnwritableException('The file is no longer writable.');
     }
     if ($this->queue->isEmpty()) {
         $awaitable = $this->push($data);
     } else {
         $awaitable = $this->queue->top();
         $awaitable = $awaitable->then(function () use($data) {
             return $this->push($data);
         });
     }
     $this->queue->push($awaitable);
     if ($end) {
         $this->writable = false;
     }
     if ($timeout) {
         $awaitable = $awaitable->timeout($timeout);
     }
     $this->poll->listen();
     try {
         $result = (yield $awaitable);
     } catch (\Exception $exception) {
         $this->close();
         throw $exception;
     } finally {
         if ($end) {
             $this->close();
         }
         $this->poll->done();
     }
     return $result;
 }
开发者ID:sternt,项目名称:filesystem,代码行数:47,代码来源:EioFile.php

示例10: send

 /**
  * @coroutine
  *
  * @param string $data
  * @param float|int $timeout
  * @param bool $end
  *
  * @return \Generator
  *
  * @resolve int Number of bytes written to the stream.
  *
  * @throws \Icicle\Stream\Exception\UnwritableException If the stream is no longer writable.
  */
 protected function send(string $data, float $timeout = 0, bool $end = false) : \Generator
 {
     if (!$this->isWritable()) {
         throw new UnwritableException('The stream is no longer writable.');
     }
     $this->buffer->push($data);
     if (null !== $this->delayed && !$this->buffer->isEmpty()) {
         $delayed = $this->delayed;
         $this->delayed = null;
         $delayed->resolve($this->remove());
     }
     if ($end) {
         if ($this->buffer->isEmpty()) {
             $this->free();
         } else {
             $this->writable = false;
         }
     }
     if (0 !== $this->hwm && $this->buffer->getLength() > $this->hwm) {
         $awaitable = new Delayed($this->onCancelled = $this->onCancelled ?: function () {
             $this->free();
         });
         $this->queue->push($awaitable);
         if ($timeout) {
             $awaitable = $awaitable->timeout($timeout);
         }
         (yield $awaitable);
     }
     return strlen($data);
 }
开发者ID:icicleio,项目名称:stream,代码行数:43,代码来源:MemoryStream.php

示例11: doQuery

 /**
  * @param string $sql
  * @param callable $callback
  */
 protected function doQuery($sql, callable $callback)
 {
     //remove from idle pool
     $db = array_pop($this->idle_pool);
     /**
      * @var \mysqli $mysqli
      */
     $mysqli = $db['object'];
     for ($i = 0; $i < 2; $i++) {
         $result = $mysqli->query($sql, MYSQLI_ASYNC);
         if ($result === false) {
             if ($mysqli->errno == 2013 or $mysqli->errno == 2006) {
                 $mysqli->close();
                 $r = $mysqli->connect();
                 if ($r === true) {
                     continue;
                 }
             } else {
                 #echo "server exception. \n";
                 $this->connection_num--;
                 $this->wait_queue->push(array('sql' => $sql, 'callback' => $callback));
                 return;
             }
         }
         break;
     }
     $task['sql'] = $sql;
     $task['callback'] = $callback;
     $task['mysql'] = $db;
     //join to work pool
     $this->work_pool[$db['socket']] = $task;
 }
开发者ID:mahuatengBC,项目名称:framework,代码行数:36,代码来源:MySQL.php

示例12: push

 public function push($value)
 {
     if (!$value instanceof Task) {
         throw new \InvalidArgumentException("TaskQueue expects instance of Task only");
     }
     parent::push($value);
 }
开发者ID:nikita2206,项目名称:poller,代码行数:7,代码来源:TaskQueue.php

示例13: doQuery

 /**
  * @param string $sql
  * @param callable $callback
  */
 protected function doQuery($sql, callable $callback)
 {
     deQueue:
     //remove from idle pool
     $db = array_pop($this->idle_pool);
     /**
      * @var \mysqli $mysqli
      */
     $mysqli = $db['object'];
     if ($this->haveSwooleAsyncMySQL) {
         $result = swoole_mysql_query($mysqli, $sql, array($this, 'onSQLReady'));
     } else {
         $result = $mysqli->query($sql, MYSQLI_ASYNC);
     }
     if ($result === false) {
         if ($mysqli->errno == 2013 or $mysqli->errno == 2006 or isset($mysqli->_errno) and $mysqli->_errno == 2006) {
             $mysqli->close();
             unset($mysqli);
             $this->connection_num--;
             //创建连接成功
             if ($this->createConnection() === 0) {
                 goto deQueue;
             }
         } else {
             $this->wait_queue->push(array('sql' => $sql, 'callback' => $callback));
             return;
         }
     }
     $task['sql'] = $sql;
     $task['callback'] = $callback;
     $task['mysql'] = $db;
     //join to work pool
     $this->work_pool[$db['socket']] = $task;
 }
开发者ID:kilmas,项目名称:framework,代码行数:38,代码来源:MySQL.php

示例14: receive

 /**
  * Receive a value from the channel.
  * 
  * Be careful when you may receive null values: you need to change the EOF param accordingly!
  * 
  * @param mixed $eof The EOF value, a channel will return this value if it has been closed without an error.
  * @return mixed The received value.
  * 
  * @throws \Throwable Fails if the channel has been closed with an error.
  */
 public function receive($eof = null) : Awaitable
 {
     if (!$this->buffer) {
         while ($this->senders && !$this->senders->isEmpty()) {
             $subscription = $this->senders->dequeue();
             if ($subscription->active) {
                 $subscription->resolve($subscription->data);
                 return new Success($subscription->data);
             }
         }
     } elseif (!$this->buffer->isEmpty()) {
         while ($this->senders && !$this->senders->isEmpty()) {
             $subscription = $this->senders->dequeue();
             if ($subscription->active) {
                 $subscription->resolve($subscription->data);
                 $this->buffer->push($subscription->data);
             }
         }
         return new Success($this->buffer->dequeue());
     }
     if ($this->closed instanceof \Throwable) {
         return new Failure($this->closed);
     } elseif ($this->closed) {
         return new Success($eof);
     }
     if (!$this->receivers) {
         $this->receivers = new \SplQueue();
     }
     $this->receivers->enqueue($subscription = new ChannelSubscription($eof));
     return $subscription;
 }
开发者ID:koolkode,项目名称:async,代码行数:41,代码来源:Channel.php

示例15: push

 /**
  * @param \Icicle\Postgres\Connection $connection
  *
  * @throws \Icicle\Exception\InvalidArgumentError
  */
 private function push(Connection $connection)
 {
     if (!isset($this->connections[$connection])) {
         throw new InvalidArgumentError('Connection is not part of this pool');
     }
     $this->idle->push($connection);
     if ($this->awaitable instanceof Delayed) {
         $this->awaitable->resolve($connection);
     }
 }
开发者ID:icicleio,项目名称:postgres,代码行数:15,代码来源:AbstractPool.php


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