Changeset

9745:0dbb285f903e

util.promise: Remove references to callbacks after settling promise This is to help the garbage collector.
author Kim Alvefur <zash@zash.se>
date Sun, 30 Dec 2018 03:24:54 +0100
parents 9744:8132030ff04a
children 9746:848fd204708c
files util/promise.lua
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/promise.lua	Sun Dec 30 03:20:37 2018 +0100
+++ b/util/promise.lua	Sun Dec 30 03:24:54 2018 +0100
@@ -49,6 +49,9 @@
 	for _, cb in ipairs(cbs) do
 		cb(value);
 	end
+	-- No need to keep references to callbacks
+	promise._pending_on_fulfilled = nil;
+	promise._pending_on_rejected = nil;
 	return true;
 end