Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add self.queueMicrotask() #2789

Merged
merged 2 commits into from
Aug 1, 2018
Merged

Add self.queueMicrotask() #2789

merged 2 commits into from
Aug 1, 2018

Conversation

domenic
Copy link
Member

@domenic domenic commented Jun 23, 2017

Closes #512.

Tests: web-platform-tests/wpt#6334

Chrome is tentatively interested in implementing this, so I'm getting a spec and tests up for review. The actual spec is a one-liner that does what you expect, but I tried to capture some of the discussions from #512 about when this is and isn't appropriate.

Let's continue using #512 for discussion on the merits of this feature, instead of forking the discussion into this PR.


/comms.html ( diff )
/imagebitmap-and-animations.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/references.html ( diff )
/system-state.html ( diff )
/timers-and-user-prompts.html ( diff )
/webappapis.html ( diff )

@domenic domenic added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest needs tests Moving the issue forward requires someone to write tests labels Jun 23, 2017
domenic added a commit to web-platform-tests/wpt that referenced this pull request Jun 23, 2017
@domenic domenic removed the needs tests Moving the issue forward requires someone to write tests label Jun 28, 2017
@@ -89383,7 +89394,7 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
<p>To affect the world of observable JavaScript objects, then, you must <span>queue a task</span>
to perform any such manipulations. This ensures your steps are properly interleaved with respect
to other things happening on the <span>event loop</span>. Furthermore, you must choose a
<span>task source</span> when <span data-x="queue a task">queueing a task</span>; this governs the
<span>task source</span> when <span data-x="queue a task">queuing a task</span>; this governs the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are correct so we should add this to the Style Guide.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -90402,6 +90413,9 @@ interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {
long <span data-x="dom-setInterval">setInterval</span>(<span>TimerHandler</span> handler, optional long timeout = 0, any... arguments);
void <span data-x="dom-clearInterval">clearInterval</span>(optional long handle = 0);

// microtask queuing
void <span data-x="dom-queueMicrotask">queueMicrotask</span>(<span data-x="idl-Function">Function</span> <var>callback</var>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be available in worklets? cc @padenot @bfgeek @nhiroki

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see a reason why they wouldn't have this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to explore that separately, if so. There is no shared mixin right now so doing so is not straightforward. And from what I understand not all worklets have event loops?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They all have an event loop I believe. They just don't queue new tasks, but that doesn't matter here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also, wouldn't that mean we'd add a new mixin that encompasses all? Or would we solve it differently?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't know what the right solution is. I'd like to work on such an expansion in collaboration with the worklets editors, as a new feature, instead of holding up this (implementer consensus/tests ready/spec ready) feature on figuring out the details.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm okay with that, provided there's a follow-up issue. I do think it'll result in this method being moved to a new mixin, but so be it.

<h3>Microtask queuing</h3>

<p>The <code data-x="dom-queueMicrotask">queueMicrotask()</code> method allows authors to schedule
a callback on the <span>microtask queue</span>. This allows their code to run after the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it's at the end of the task, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source Outdated
browser's <span>event loop</span>, as would be the case when using, for example, <code
data-x="dom-setTimeout">setTimeout(<var>f</var>,&nbsp;0)</code>.</p>

<p>Authors should be aware that scheduling a lot of microtasks has the same performance downsides
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should -> ought to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

domenic added a commit to whatwg/whatwg.org that referenced this pull request Jul 23, 2018
@domenic domenic removed the needs implementer interest Moving the issue forward requires implementers to express interest label Jul 23, 2018
annevk pushed a commit to whatwg/whatwg.org that referenced this pull request Jul 25, 2018
@annevk
Copy link
Member

annevk commented Jul 25, 2018

(This also still needs implementation bugs.)

@domenic domenic merged commit 9d7cf12 into master Aug 1, 2018
@domenic domenic deleted the enqueue-microtask branch August 1, 2018 21:28
domenic added a commit to web-platform-tests/wpt that referenced this pull request Aug 1, 2018
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 4, 2018
…stonly

Automatic update from web-platform-testsAdd tests for self.queueMicrotask()

Follows whatwg/html#2789.
--

wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df
wpt-pr: 6334
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Aug 4, 2018
…stonly

Automatic update from web-platform-testsAdd tests for self.queueMicrotask()

Follows whatwg/html#2789.
--

wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df
wpt-pr: 6334
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…stonly

Automatic update from web-platform-testsAdd tests for self.queueMicrotask()

Follows whatwg/html#2789.
--

wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df
wpt-pr: 6334

UltraBlame original commit: 141be436c496b0715eac4f3a7c0c6a0c25392a59
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…stonly

Automatic update from web-platform-testsAdd tests for self.queueMicrotask()

Follows whatwg/html#2789.
--

wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df
wpt-pr: 6334

UltraBlame original commit: 141be436c496b0715eac4f3a7c0c6a0c25392a59
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…stonly

Automatic update from web-platform-testsAdd tests for self.queueMicrotask()

Follows whatwg/html#2789.
--

wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df
wpt-pr: 6334

UltraBlame original commit: 141be436c496b0715eac4f3a7c0c6a0c25392a59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements topic: event loop
Development

Successfully merging this pull request may close these issues.

None yet

3 participants