Skip to content

Commit d39e57d

Browse files
moved timersgc foreach loop into callback
1 parent 1a97b4d commit d39e57d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/React/EventLoop/LibEventLoop.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,6 @@ protected function addTimerInternal($interval, $callback, $periodic = false)
161161
throw new \InvalidArgumentException('The callback must be a callable object.');
162162
}
163163

164-
foreach ($this->timersGc as $resource) {
165-
event_free($resource);
166-
}
167-
168164
$timer = (object) array(
169165
'loop' => $this,
170166
'resource' => $resource = event_new(),
@@ -177,6 +173,9 @@ protected function addTimerInternal($interval, $callback, $periodic = false)
177173
$timer->signature = spl_object_hash($timer);
178174

179175
$callback = function () use ($timer) {
176+
foreach ($this->timersGc as $resource) {
177+
event_free($resource);
178+
}
180179
if ($timer->cancelled === false) {
181180
call_user_func($timer->callback, $timer->signature, $timer->loop);
182181

0 commit comments

Comments
 (0)