File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -16,21 +16,40 @@ void PromiseProxy::Init(v8::Local<v8::Context> context) {
16
16
let runloop = CFRunLoopGetCurrent();
17
17
18
18
let promise = new target(function(resolve, reject) {
19
+ function isFulfilled() {
20
+ return !resolve;
21
+ }
22
+ function markFulfilled() {
23
+ runloop = null;
24
+ origFunc = null;
25
+ resolve = null;
26
+ reject = null;
27
+ }
19
28
origFunc(value => {
29
+ if (isFulfilled()) {
30
+ return;
31
+ }
20
32
const resolveCall = resolve.bind(this, value);
21
33
if (runloop === CFRunLoopGetCurrent()) {
34
+ markFulfilled();
22
35
resolveCall();
23
36
} else {
24
37
CFRunLoopPerformBlock(runloop, kCFRunLoopDefaultMode, resolveCall);
25
38
CFRunLoopWakeUp(runloop);
39
+ markFulfilled();
26
40
}
27
41
}, reason => {
42
+ if (isFulfilled()) {
43
+ return;
44
+ }
28
45
const rejectCall = reject.bind(this, reason);
29
46
if (runloop === CFRunLoopGetCurrent()) {
47
+ markFulfilled();
30
48
rejectCall();
31
49
} else {
32
50
CFRunLoopPerformBlock(runloop, kCFRunLoopDefaultMode, rejectCall);
33
51
CFRunLoopWakeUp(runloop);
52
+ markFulfilled();
34
53
}
35
54
});
36
55
});
You can’t perform that action at this time.
0 commit comments