7
7
8
8
"capnproto.org/go/capnp/v3/exc"
9
9
"capnproto.org/go/capnp/v3/internal/str"
10
+ "zenhack.net/go/util/deferred"
10
11
"zenhack.net/go/util/sync/mutex"
11
12
)
12
13
@@ -135,7 +136,8 @@ func (p *Promise) Reject(e error) {
135
136
// If e != nil, then this is equivalent to p.Reject(e).
136
137
// Otherwise, it is equivalent to p.Fulfill(r).
137
138
func (p * Promise ) Resolve (r Ptr , e error ) {
138
- var shutdownPromises []* clientPromise
139
+ dq := & deferred.Queue {}
140
+ defer dq .Run ()
139
141
140
142
// It's ok to extract p.clients and use it while not holding the lock:
141
143
// it may not be accessed in the pending resolution state, so we have
@@ -155,8 +157,7 @@ func (p *Promise) Resolve(r Ptr, e error) {
155
157
res := resolution {p .method , r , e }
156
158
for path , cp := range clients {
157
159
t := path .transform ()
158
- cp .promise .fulfill (res .client (t ))
159
- shutdownPromises = append (shutdownPromises , cp .promise )
160
+ cp .promise .fulfill (dq , res .client (t ))
160
161
cp .promise = nil
161
162
}
162
163
@@ -168,9 +169,6 @@ func (p *Promise) Resolve(r Ptr, e error) {
168
169
}
169
170
p .signals = nil
170
171
})
171
- for _ , promise := range shutdownPromises {
172
- promise .shutdown ()
173
- }
174
172
}
175
173
176
174
// requireUnresolved is a helper method for checking for duplicate
0 commit comments