From 944a2dd29d4d4b7b8a8a389d1f8d34cd9f62ea69 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Mon, 20 May 2019 20:32:19 +0200 Subject: [PATCH] Move Coroutine::__destruct to Placeholder --- lib/Coroutine.php | 11 ----------- lib/Internal/Placeholder.php | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Coroutine.php b/lib/Coroutine.php index 8b1c037..071622e 100644 --- a/lib/Coroutine.php +++ b/lib/Coroutine.php @@ -144,15 +144,4 @@ final class Coroutine implements Promise }); } } - - public function __destruct() - { - try { - $this->result = null; - } catch (\Throwable $e) { - Loop::defer(static function () use ($e) { - throw $e; - }); - } - } } diff --git a/lib/Internal/Placeholder.php b/lib/Internal/Placeholder.php index 6a0936e..92b487c 100644 --- a/lib/Internal/Placeholder.php +++ b/lib/Internal/Placeholder.php @@ -155,4 +155,15 @@ trait Placeholder { $this->resolve(new Failure($reason)); } + + public function __destruct() + { + try { + $this->result = null; + } catch (\Throwable $e) { + Loop::defer(static function () use ($e) { + throw $e; + }); + } + } }