W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > July 2019

Re: [webrtc-pc] Operations "queue" is a misnomer. Confuses people. (#2227)

From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
Date: Fri, 12 Jul 2019 17:32:14 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issue_comment.created-510969504-1562952733-sysbot+gh@w3.org>
To illustrate the difference between a (main thread) task and an operetion:

This click triggers one task (one synchronous operation):
```js
button.onclick = () => {
    video1.pause();
    video2.pause();
    video3.pause();
}
```
This click triggers 3 tasks (one asynchronous operation):
```js
button.onclick = async () => {
    await video1.play();
    await video2.play();
    await video3.play();
}
```
...because it is syntactic sugar for:
```js
button.onclick = () => {
  return video1.play()          // synchronously invoked
    .then(() => video2.play())  // a callback
    .then(() => video3.play()); // another callback
}
```
(A fourth task may resolve the final returned promise, but it might be GC'ed since it's unused).

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2227#issuecomment-510969504 using your GitHub account
Received on Friday, 12 July 2019 17:32:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:22:25 UTC