Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #27 from WyriHaximus/tick-queue
Browse files Browse the repository at this point in the history
Tick queue in a periodic timer for each request
  • Loading branch information
WyriHaximus committed Apr 23, 2018
2 parents 698d62c + 95eec3d commit 16ef0bd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/HttpClientAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use React\Dns\Resolver\Factory as DnsFactory;
use React\Dns\Resolver\Resolver as DnsResolver;
use React\EventLoop\LoopInterface;
use React\EventLoop\Timer\TimerInterface;
use React\HttpClient\Client as HttpClient;
use React\HttpClient\Client;
use React\HttpClient\Factory as HttpClientFactory;
Expand Down Expand Up @@ -175,6 +176,14 @@ function ($error) use (&$ready, $promise) {
)
;

/** @var TimerInterface $timer */
$timer = $this->loop->addPeriodicTimer(static::QUEUE_TIMER_INTERVAL, function () use (&$ready, &$timer) {
$this->invokeQueue();
if ($ready) {
$this->loop->cancelTimer($timer);
}
});

return $promise;
}

Expand Down

0 comments on commit 16ef0bd

Please sign in to comment.