From a460fe969d842f54a22424e53f566c7230d5f2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 19 Apr 2018 18:01:11 +0200 Subject: [PATCH] Improve memory consumption by cleaning up unneeded references --- src/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/functions.php b/src/functions.php index 6ad9867..d59d236 100644 --- a/src/functions.php +++ b/src/functions.php @@ -55,10 +55,12 @@ function resolve($time, LoopInterface $loop) $timer = $loop->addTimer($time, function () use ($time, $resolve) { $resolve($time); }); - }, function ($resolveUnused, $reject) use (&$timer, $loop) { + }, function ($resolve, $reject, $notify) use (&$timer, $loop) { // cancelling this promise will cancel the timer and reject $loop->cancelTimer($timer); - $reject(new \RuntimeException('Timer cancelled')); + + $resolve = $reject = $notify = $timer = $loop = null; + throw new \RuntimeException('Timer cancelled'); }); }