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


PHP LoopInterface::cancelTimer方法代码示例

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


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

示例1: run

 public function run()
 {
     $this->deferred = new Deferred();
     $this->deferred->promise()->progress(function ($event) {
         $this->data[$event['part']] = $event['data'];
         unset($this->unsettled[$event['part']]);
         if ($this->isEverythingHasBeenReceived()) {
             $this->deferred->resolve();
         }
     })->then(function () {
         if (isset($this->cancel_timer)) {
             $this->loop->cancelTimer($this->cancel_timer);
             unset($this->cancel_timer);
         }
     })->done(function () {
         $response = call_user_func($this->then_callback, $this->data);
         $headers = ['Content-Type' => 'text/plain'];
         $this->response->writeHead(200, $headers);
         $this->response->end($response);
     }, function () {
         $headers = ['Content-Type' => 'text/plain'];
         $this->response->writeHead(404, $headers);
         $this->response->end("Failed");
     });
     if (empty($this->requests)) {
         $this->deferred->resolve();
     } else {
         $this->registerCancelTimer();
         foreach ($this->requests as $request) {
             $request->end();
         }
     }
     return $this;
 }
开发者ID:akond,项目名称:reactphp-example,代码行数:34,代码来源:timed-poll-2.php

示例2: close

 public function close()
 {
     if ($this->closed) {
         return;
     }
     $this->loop->cancelTimer($this->timer);
     unset($this->queue);
     $this->closed = true;
 }
开发者ID:loobee,项目名称:ddd,代码行数:9,代码来源:AmqpExchangeListener.php

示例3: cancelPeriodicTimer

 /**
  * @param string $name
  */
 public function cancelPeriodicTimer($tidOrname)
 {
     if (!isset($this->registry[$tidOrname])) {
         $tid = $this->getTid($tidOrname);
     } else {
         $tid = $tidOrname;
     }
     $timer = $this->registry[$tid];
     $this->loop->cancelTimer($timer);
     unset($this->registry[$tid]);
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:14,代码来源:ConnectionPeriodicTimer.php

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

示例5: __construct

 public function __construct(TransportInterface $carrierProtocol, LoopInterface $loop, LoggerInterface $logger)
 {
     $that = $this;
     $this->logger = $logger;
     $this->loop = $loop;
     $this->carrierProtocol = $carrierProtocol;
     $this->actionEmitter = new EventEmitter();
     $deferreds =& $this->deferred;
     $timers =& $this->timers;
     $carrierProtocol->on("message", function (MessageInterface $message) use(&$deferreds, &$timers, &$loop, $that, $logger) {
         $string = $message->getData();
         try {
             $jsonMessage = RemoteEventMessage::fromJson($string);
             $tag = $jsonMessage->getTag();
             if (array_key_exists($tag, $deferreds)) {
                 $deferred = $deferreds[$tag];
                 unset($deferreds[$tag]);
                 if (array_key_exists($tag, $timers)) {
                     $loop->cancelTimer($timers[$tag]);
                     unset($timers[$tag]);
                 }
                 $deferred->resolve($jsonMessage);
             } else {
                 $that->remoteEvent()->emit($jsonMessage->getEvent(), array($jsonMessage));
             }
             $that->emit("message", array($jsonMessage));
         } catch (\Exception $e) {
             $logger->err("Exception while parsing JsonMessage: " . $e->getMessage());
         }
     });
 }
开发者ID:rb-cohen,项目名称:phpws,代码行数:31,代码来源:RemoteEventTransport.php

示例6: wait

 /**
  * @param string $captchaId
  * @return Promise\Promise
  */
 public function wait($captchaId)
 {
     $deferred = new Promise\Deferred();
     $this->loop->addPeriodicTimer($this->requestInterval, function ($timer) use($deferred, $captchaId) {
         $request = $this->client->request($this->getResultMethod(), $this->getResultPath(), ['Content-Length' => strlen($this->getResultQuery($captchaId)), 'Content-Type' => 'application/x-www-form-urlencoded']);
         $request->on('response', function ($response) use($request, $deferred, $timer) {
             /** @var \React\HttpClient\Response $response */
             $response->on('data', function ($data, $response) use($request, $deferred, $timer) {
                 /** @var \GuzzleHttp\Psr7\Stream $data */
                 /** @var \React\HttpClient\Response $response */
                 $response->handleEnd();
                 $answer = $data->getContents();
                 // stream read
                 if (!$answer) {
                     $this->loop->cancelTimer($timer);
                     $deferred->reject(new ServiceException('ERROR_CONNECTION'));
                 } elseif (substr($answer, 0, 2) === 'OK') {
                     $this->loop->cancelTimer($timer);
                     $deferred->resolve(substr($answer, 3));
                 } elseif ($answer !== 'CAPCHA_NOT_READY') {
                     $this->loop->cancelTimer($timer);
                     $deferred->reject(new ServiceException($answer));
                 }
             });
         });
         $request->end($this->getResultQuery($captchaId));
     });
     return $deferred->promise();
 }
开发者ID:xRubin,项目名称:async-anticaptcha,代码行数:33,代码来源:ServiceAbstract.php

示例7: cancelPeriodicTimer

 /**
  * @param TopicInterface $topic
  * @param string         $name
  */
 public function cancelPeriodicTimer(TopicInterface $topic, $name)
 {
     $namespace = spl_object_hash($topic);
     if (isset($this->registry[$namespace][$name])) {
         return;
     }
     $timer = $this->registry[$namespace][$name];
     $this->loop->cancelTimer($timer);
     unset($this->registry[$namespace][$name]);
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:14,代码来源:TopicPeriodicTimer.php

示例8: postponeMaintenance

 /**
  * Postpone the maintenance run
  */
 public function postponeMaintenance()
 {
     if ($this->maintenanceTimer) {
         $this->eventLoop->cancelTimer($this->maintenanceTimer);
     }
     $this->maintenanceTimer = $this->eventLoop->addTimer($this->maintenanceInterval, function ($timer) {
         $this->runMaintenance();
         $this->postponeMaintenance();
     });
 }
开发者ID:marviktintor,项目名称:pos-1,代码行数:13,代码来源:AbstractServer.php

示例9: close

 /**
  * Method to call when stopping listening to messages.
  */
 public function close()
 {
     if ($this->closed) {
         return;
     }
     $this->emit('end', [$this]);
     $this->loop->cancelTimer($this->timer);
     $this->removeAllListeners();
     unset($this->exchange);
     $this->closed = true;
 }
开发者ID:GeniusesOfSymfony,项目名称:ReactAMQP,代码行数:14,代码来源:Producer.php

示例10: cancelReminder

 /**
  * Cancel a running timer
  *
  * @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event
  * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
  */
 public function cancelReminder(Event $event, Queue $queue)
 {
     extract($this->parseReminder($event));
     if (isset($this->activeTimers[$nick][$name])) {
         $this->loop->cancelTimer($this->activeTimers[$nick][$name]);
         unset($this->activeTimers[$nick][$name]);
         $queue->{$command}($source, "{$nick}: The {$name} reminder has been cancelled.");
     } else {
         $queue->{$command}($source, "{$nick}: That reminder isn't running.");
     }
 }
开发者ID:sitedyno,项目名称:phergie-reminders,代码行数:17,代码来源:Plugin.php

示例11: resolve

function resolve($time, LoopInterface $loop)
{
    return new Promise(function ($resolve) use($loop, $time, &$timer) {
        // resolve the promise when the timer fires in $time seconds
        $timer = $loop->addTimer($time, function () use($time, $resolve) {
            $resolve($time);
        });
    }, function ($resolveUnused, $reject) use(&$timer, $loop) {
        // cancelling this promise will cancel the timer and reject
        $loop->cancelTimer($timer);
        $reject(new \RuntimeException('Timer cancelled'));
    });
}
开发者ID:clue,项目名称:promise-timeout,代码行数:13,代码来源:functions.php

示例12: onEnd

 /**
  *
  */
 protected function onEnd()
 {
     if ($this->requestTimer !== null && $this->loop->isTimerActive($this->requestTimer)) {
         $this->loop->cancelTimer($this->requestTimer);
     }
     if ($this->connectionTimer !== null && $this->loop->isTimerActive($this->connectionTimer)) {
         $this->loop->cancelTimer($this->connectionTimer);
     }
     $this->loop->futureTick(function () {
         if ($this->httpResponse === null) {
             $this->deferred->reject($this->error);
         }
     });
 }
开发者ID:wyrihaximus,项目名称:react-guzzle-http-client,代码行数:17,代码来源:Request.php

示例13: handleClose

 /**
  * Handles closing of the stream.
  */
 private function handleClose()
 {
     foreach ($this->timer as $timer) {
         $this->loop->cancelTimer($timer);
     }
     $connection = $this->connection;
     $this->isConnecting = false;
     $this->isDisconnecting = false;
     $this->isConnected = false;
     $this->connection = null;
     $this->stream = null;
     if ($connection !== null) {
         $this->emit('close', [$connection, $this]);
     }
 }
开发者ID:binsoul,项目名称:net-mqtt-client-react,代码行数:18,代码来源:ReactMqttClient.php

示例14: closure

 /**
  * @param Server        $server
  * @param LoopInterface $loop
  */
 protected function closure(Server $server, LoopInterface $loop)
 {
     $this->logger->notice('Stopping server ...');
     foreach ($this->serverPushHandlerRegistry->getPushers() as $handler) {
         $handler->close();
         $this->logger->info(sprintf('Stop %s push handler', $handler->getName()));
     }
     $server->emit('end');
     $server->shutdown();
     foreach ($this->periodicRegistry->getPeriodics() as $periodic) {
         if ($periodic instanceof TimerInterface && $loop->isTimerActive($periodic)) {
             $loop->cancelTimer($periodic);
         }
     }
     $loop->stop();
     $this->logger->notice('Server stopped !');
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:21,代码来源:StartServerListener.php

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


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