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


PHP LoopInterface::removeWriteStream方法代码示例

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


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

示例1: del

 /**
  * Remove event listener from event loop.
  *
  * @param mixed $fd
  * @param int   $flag
  * @return bool
  */
 public function del($fd, $flag)
 {
     switch ($flag) {
         case EventInterface::EV_READ:
             return $this->_loop->removeReadStream($fd);
         case EventInterface::EV_WRITE:
             return $this->_loop->removeWriteStream($fd);
         case EventInterface::EV_SIGNAL:
             return $this->_loop->removeSignal($fd);
         case EventInterface::EV_TIMER:
         case EventInterface::EV_TIMER_ONCE:
             return $this->_loop->cancelTimer($fd);
     }
     return false;
 }
开发者ID:walkor,项目名称:workerman,代码行数:22,代码来源:React.php

示例2: handleWriteEvent

 public function handleWriteEvent()
 {
     foreach ($this->messages as $i => $message) {
         try {
             if (!is_array($message)) {
                 $message = array($message);
             }
             $sent = (bool) $this->socket->sendmulti($message, ZMQ::MODE_NOBLOCK);
             if ($sent) {
                 unset($this->messages[$i]);
                 if (0 === count($this->messages)) {
                     $this->loop->removeWriteStream($this->fileDescriptor);
                     $this->listening = false;
                     $this->emit('end');
                 }
             }
         } catch (ZMQSocketException $e) {
             $this->emit('error', array($e));
         }
     }
 }
开发者ID:siosphere,项目名称:zmq,代码行数:21,代码来源:Buffer.php

示例3: testRecursiveFutureTick

 public function testRecursiveFutureTick()
 {
     $stream = $this->createStream();
     $this->loop->addWriteStream($stream, function () use($stream) {
         echo 'stream' . PHP_EOL;
         $this->loop->removeWriteStream($stream);
     });
     $this->loop->futureTick(function () {
         echo 'future-tick-1' . PHP_EOL;
         $this->loop->futureTick(function () {
             echo 'future-tick-2' . PHP_EOL;
         });
     });
     $this->expectOutputString('future-tick-1' . PHP_EOL . 'stream' . PHP_EOL . 'future-tick-2' . PHP_EOL);
     $this->loop->run();
 }
开发者ID:smileytechguy,项目名称:nLine,代码行数:16,代码来源:AbstractLoopTest.php

示例4: cancel

 /**
  * Cancel an existing timer/stream watcher
  *
  * @param int $watcherId
  */
 public function cancel($watcherId)
 {
     if (isset($this->watchers[$watcherId])) {
         list($type, $data) = $this->watchers[$watcherId];
         switch ($type) {
             case self::WATCHER_TYPE_READ:
                 $this->reactor->removeReadStream($data);
                 break;
             case self::WATCHER_TYPE_WRITE:
                 $this->reactor->removeWriteStream($data);
                 break;
             case self::WATCHER_TYPE_TIMER:
                 $this->reactor->cancelTimer($data);
                 break;
         }
     }
     unset($this->watchers[$watcherId], $this->disabledWatchers[$watcherId]);
 }
开发者ID:daverandom,项目名称:loopio,代码行数:23,代码来源:Loop.php

示例5: flushWriteBuffer

 /**
  * Asynchronously sends buffered data over the wire.
  *
  * - Calls {@link eventLoops}'s addWriteStream() with client's stream.
  * - Consecutive calls will return the same instance of promise.
  *
  * @return Promise\PromiseInterface
  */
 protected function flushWriteBuffer()
 {
     if ($this->flushWriteBufferPromise) {
         return $this->flushWriteBufferPromise;
     } else {
         $deferred = new Promise\Deferred();
         $this->eventLoop->addWriteStream($this->getStream(), function ($stream) use($deferred) {
             try {
                 $this->write();
                 if ($this->writeBuffer->isEmpty()) {
                     $this->eventLoop->removeWriteStream($stream);
                     $this->flushWriteBufferPromise = null;
                     $deferred->resolve(true);
                 }
             } catch (\Exception $e) {
                 $this->eventLoop->removeWriteStream($stream);
                 $this->flushWriteBufferPromise = null;
                 $deferred->reject($e);
             }
         });
         return $this->flushWriteBufferPromise = $deferred->promise();
     }
 }
开发者ID:Andrewsville,项目名称:bunny,代码行数:31,代码来源:Client.php

示例6: removeWriteStream

 /**
  * Remove the write event listener for the given stream.
  *
  * @param stream $stream The PHP stream resource.
  */
 public function removeWriteStream($stream)
 {
     $this->emit('removeWriteStream', [$stream]);
     $this->loop->removeWriteStream($stream);
 }
开发者ID:WyriHaximus,项目名称:reactphp-event-loop-inspector,代码行数:10,代码来源:LoopDecorator.php


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