Software /
code /
prosody
Comparison
util/promise.lua @ 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 |
parent | 9562:acf74ad0b795 |
child | 10922:7d3dbb9eb3eb |
comparison
equal
deleted
inserted
replaced
9744:8132030ff04a | 9745:0dbb285f903e |
---|---|
47 promise._state = new_state; | 47 promise._state = new_state; |
48 promise._next = new_next; | 48 promise._next = new_next; |
49 for _, cb in ipairs(cbs) do | 49 for _, cb in ipairs(cbs) do |
50 cb(value); | 50 cb(value); |
51 end | 51 end |
52 -- No need to keep references to callbacks | |
53 promise._pending_on_fulfilled = nil; | |
54 promise._pending_on_rejected = nil; | |
52 return true; | 55 return true; |
53 end | 56 end |
54 | 57 |
55 local function new_resolve_functions(p) | 58 local function new_resolve_functions(p) |
56 local resolved = false; | 59 local resolved = false; |