本文整理汇总了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;
}
示例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));
}
}
}
示例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();
}
示例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]);
}
示例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();
}
}
示例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);
}