File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ public function getTime()
3030 public function add (TimerInterface $ timer )
3131 {
3232 $ interval = $ timer ->getInterval ();
33- $ scheduledAt = $ interval + $ this -> getTime ( );
33+ $ scheduledAt = $ interval + microtime ( true );
3434
3535 $ this ->timers ->attach ($ timer , $ scheduledAt );
3636 $ this ->scheduler ->insert ($ timer , -$ scheduledAt );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Tests \EventLoop \Timer ;
4+
5+ use React \Tests \EventLoop \TestCase ;
6+ use React \EventLoop \Timer \Timer ;
7+ use React \EventLoop \Timer \Timers ;
8+
9+ class TimersTest extends TestCase
10+ {
11+ public function testBlockedTimer ()
12+ {
13+ $ loop = $ this
14+ ->getMockBuilder ('React\EventLoop\LoopInterface ' )
15+ ->getMock ();
16+
17+ $ timers = new Timers ();
18+ $ timers ->tick ();
19+
20+ // simulate a bunch of processing on stream events,
21+ // part of which schedules a future timer...
22+ sleep (1 );
23+ $ timers ->add (new Timer ($ loop , 0.5 , function () {
24+ $ this ->fail ("Timer shouldn't be called " );
25+ }));
26+
27+ $ timers ->tick ();
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments