File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ public function getTime()
30
30
public function add (TimerInterface $ timer )
31
31
{
32
32
$ interval = $ timer ->getInterval ();
33
- $ scheduledAt = $ interval + $ this -> getTime ( );
33
+ $ scheduledAt = $ interval + microtime ( true );
34
34
35
35
$ this ->timers ->attach ($ timer , $ scheduledAt );
36
36
$ 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