Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 9bda3dc9faa7bfa79190c1483345d93057120349..ca0d5c0d51c2aefb2215ac76a1ea03867684e705 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -2697,17 +2697,31 @@ class V8_EXPORT Function : public Object { |
*/ |
class V8_EXPORT Promise : public Object { |
public: |
- /** |
- * Create a new Promise in pending state. |
- */ |
- static Local<Promise> New(Isolate* isolate); |
+ class V8_EXPORT Resolver : public Object { |
+ public: |
+ /** |
+ * Create a new resolver, along with an associated promise in pending state. |
+ */ |
+ static Local<Resolver> New(Isolate* isolate); |
- /** |
- * Resolve/reject a promise with a given value. |
- * Ignored if the promise is not unresolved. |
- */ |
- void Resolve(Handle<Value> value); |
- void Reject(Handle<Value> value); |
+ /** |
+ * Extract the associated promise. |
+ */ |
+ Local<Promise> GetPromise(); |
+ |
+ /** |
+ * Resolve/reject the associated promise with a given value. |
+ * Ignored if the promise is no longer pending. |
+ */ |
+ void Resolve(Handle<Value> value); |
+ void Reject(Handle<Value> value); |
+ |
+ V8_INLINE static Resolver* Cast(Value* obj); |
+ |
+ private: |
+ Resolver(); |
+ static void CheckCast(Value* obj); |
+ }; |
/** |
* Register a resolution/rejection handler with a promise. |
@@ -6429,6 +6443,14 @@ Promise* Promise::Cast(v8::Value* value) { |
} |
+Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) { |
+#ifdef V8_ENABLE_CHECKS |
+ CheckCast(value); |
+#endif |
+ return static_cast<Promise::Resolver*>(value); |
+} |
+ |
+ |
ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { |
#ifdef V8_ENABLE_CHECKS |
CheckCast(value); |