File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class Loop
39
39
/**
40
40
* @var bool True while code execution is repeating.
41
41
*/
42
- private $ looping ;
42
+ private $ looping = false ;
43
43
44
44
/**
45
45
* Sets the timeout. The default is 3 seconds.
@@ -57,7 +57,6 @@ public function __construct(int $timeout = 3)
57
57
}
58
58
59
59
$ this ->timeout = $ timeout ;
60
- $ this ->looping = false ;
61
60
}
62
61
63
62
/**
@@ -98,7 +97,10 @@ public function execute(callable $code)
98
97
for ($ i = 0 ; $ this ->looping && microtime (true ) < $ deadline ; ++$ i ) {
99
98
$ result = $ code ();
100
99
if (!$ this ->looping ) { // @phpstan-ignore-line
101
- break ;
100
+ /*
101
+ * The $code callback has called $this->end() and the lock has been acquired.
102
+ */
103
+ return $ result ;
102
104
}
103
105
104
106
// Calculate max time remaining, don't sleep any longer than that.
@@ -120,10 +122,6 @@ public function execute(callable $code)
120
122
usleep ($ usecToSleep );
121
123
}
122
124
123
- if (microtime (true ) >= $ deadline ) {
124
- throw TimeoutException::create ($ this ->timeout );
125
- }
126
-
127
- return $ result ;
125
+ throw TimeoutException::create ($ this ->timeout );
128
126
}
129
127
}
You can’t perform that action at this time.
0 commit comments