diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-18 10:49:36 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-18 10:49:36 +0200 |
commit | a7655a3f84c4c379328ab28b9000cd923516b412 (patch) | |
tree | 7b1e272cede88eedf56312d61c8271e8739502d5 /components/script/dom/bindings/refcounted.rs | |
parent | 851d40b204da546d5200e421439118b4e12c8d74 (diff) | |
download | servo-a7655a3f84c4c379328ab28b9000cd923516b412.tar.gz servo-a7655a3f84c4c379328ab28b9000cd923516b412.zip |
Use task! to resolve promises
Diffstat (limited to 'components/script/dom/bindings/refcounted.rs')
-rw-r--r-- | components/script/dom/bindings/refcounted.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index c11232ee70a..cdf80264edb 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -139,18 +139,14 @@ impl TrustedPromise { where T: ToJSValConvertible + Send, { - struct ResolvePromise<T>(TrustedPromise, T); - impl<T: ToJSValConvertible> Task for ResolvePromise<T> { - fn run(self: Box<Self>) { - debug!("Resolving promise."); - let this = *self; - let promise = this.0.root(); - let cx = promise.global().get_cx(); - let _ac = JSAutoCompartment::new(cx, promise.reflector().get_jsobject().get()); - promise.resolve_native(cx, &this.1); - } - } - ResolvePromise(self, value) + let this = self; + task!(resolve_promise: move || { + debug!("Resolving promise."); + let this = this.root(); + let cx = this.global().get_cx(); + let _ac = JSAutoCompartment::new(cx, this.reflector().get_jsobject().get()); + this.resolve_native(cx, &value); + }) } } |