dart-lang / site-www

Source for Dart website
https://dart.dev
Other
969 stars 700 forks source link

Document microtasks #2142

Open kwalrath opened 4 years ago

kwalrath commented 4 years ago

With the disappearance of the out-of-date article "The Event Loop and Dart", we no longer have any doc on dart.dev for microtasks. Microtasks are mentioned in /articles/archive/zones, but that article, too, is out of date.

The scheduleMicrotask API docs point to the old event loop article (/articles/event-loop, which is forwarded to the Medium article made from Andrew's event loop video). It'd be good to have actual coverage of the event loop and microtasks somewhere on dart.dev, and to redirect /articles/event-loop to that coverage.

kwalrath commented 4 years ago

Interim fix: add link from Andrew's event loop article to an archive URL like https://web.archive.org/web/20170704074724/https://webdev.dartlang.org/articles/performance/event-loop.

DONE

kwalrath commented 4 years ago

I've just discovered an internal resource that seems helpful: go/dart-await. It refers to this DartPad and this article.

kwalrath commented 2 years ago

There's a new concurrency page, but it doesn't cover microtasks: https://dart.dev/guides/language/concurrency

terryl1900 commented 2 years ago

Hi @kwalrath , searching "dart event loop" on Google, the first result is https://dart.cn/articles/archive/event-loop, which is the same as the archive URL you mentioned above.

While waiting for someone to create an updated doc, I'm curious if you know whether these points in the old doc are still true:

Fun facts about Future:

1. The function that you pass into Future’s then() method executes immediately when the Future completes. (The function isn’t enqueued, it’s just called.)
2. If a Future is already complete before then() is invoked on it, then a task is added to the microtask queue, and that task executes the function passed into then().
3. The Future() and Future.delayed() constructors don’t complete immediately; they add an item to the event queue.
4. The Future.value() constructor completes in a microtask, similar to #2.
5. The Future.sync() constructor executes its function argument immediately and (unless that function returns a Future) completes in a microtask, similar to #2.
parlough commented 2 years ago

@lrhn Would you be able to provide some input on @terryl1900's questions? We could also use your responses as guidelines when creating any new documentation around this. Thanks :)

dkbast commented 9 months ago

I believe the mentioned bugs in the article have been fixed - when running the examples they now show in the expected order (which is a bit different from what was 'then' true) - right now we are missing a good writeup on the event loop, it's also difficult to find the implementation in C, which is something I was trying to get to (the JS event loop is quite easy to find)