Last active
August 29, 2015 13:55
-
-
Save jorendorff/8724830 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Sketch of the API surface we would need to expose | |
* in order to shift the Promise implementation from dom to js/src. | |
*/ | |
namespace JS { | |
/* | |
* Microtask API. | |
* | |
* SpiderMonkey does not have its own event queue implementation. If an | |
* embedding supports Promises, it must provide an event queue | |
* implementation by calling SetEnqueueMicrotaskCallback. Promise objects | |
* will then use that callback to put Microtask pointers into the queue, | |
* and the embedding is responsibile for calling RunMicrotask on each of | |
* those pointers eventually. | |
*/ | |
struct Microtask; | |
/* | |
* The embedding provides a callback for registering a microtask. | |
*/ | |
typedef bool (*EnqueueMicrotaskCallback)(JSContext *cx, Microtask *utask); | |
JS_PUBLIC_API(bool) | |
SetEnqueueMicrotaskCallback(JSRuntime *rt, EnqueueMicrotaskCallback cb); | |
/* | |
* Execute a microtask. The event loop calls this. Call it only once per | |
* Microtask; on success or failure the microtask object is freed. | |
*/ | |
JS_PUBLIC_API(bool) | |
RunMicrotask(JSContext *cx, Microtask *utask); | |
/* | |
* Drop a microtask without running it. | |
*/ | |
JS_PUBLIC_API(bool) | |
DestroyMicrotask(JSContext *cx, Microtask *utask); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment