TimerSpeedUpEventLoop.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace React\Tests\Socket;
  3. use React\EventLoop\LoopInterface;
  4. use React\EventLoop\TimerInterface;
  5. /**
  6. * @internal
  7. */
  8. final class TimerSpeedUpEventLoop implements LoopInterface
  9. {
  10. /** @var LoopInterface */
  11. private $loop;
  12. public function __construct(LoopInterface $loop)
  13. {
  14. $this->loop = $loop;
  15. }
  16. public function addReadStream($stream, $listener)
  17. {
  18. return $this->loop->addReadStream($stream, $listener);
  19. }
  20. public function addWriteStream($stream, $listener)
  21. {
  22. return $this->loop->addWriteStream($stream, $listener);
  23. }
  24. public function removeReadStream($stream)
  25. {
  26. return $this->loop->removeReadStream($stream);
  27. }
  28. public function removeWriteStream($stream)
  29. {
  30. return $this->loop->removeWriteStream($stream);
  31. }
  32. public function addTimer($interval, $callback)
  33. {
  34. return $this->loop->addTimer($interval / 10, $callback);
  35. }
  36. public function addPeriodicTimer($interval, $callback)
  37. {
  38. return $this->loop->addPeriodicTimer($interval / 10, $callback);
  39. }
  40. public function cancelTimer(TimerInterface $timer)
  41. {
  42. return $this->loop->cancelTimer($timer);
  43. }
  44. public function futureTick($listener)
  45. {
  46. return $this->loop->futureTick($listener);
  47. }
  48. public function addSignal($signal, $listener)
  49. {
  50. return $this->loop->addSignal($signal, $listener);
  51. }
  52. public function removeSignal($signal, $listener)
  53. {
  54. return $this->loop->removeSignal($signal, $listener);
  55. }
  56. public function run()
  57. {
  58. return $this->loop->run();
  59. }
  60. public function stop()
  61. {
  62. return $this->loop->stop();
  63. }
  64. }