owned this note changed 4 years ago
Linked with GitHub

探討 JavaScript 中的 synchronization & concurrency - 以 TypeScript 打造的開源 task queue library 為例 - Grimmer

tags: COSCUP2021 zh-tw COSCUP2021 COSCUP 主議程軌 RB105 - Main Track

歡迎來到 https://hackmd.io/@coscup/2021 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。

請從這裡開始

d4c-queue: https://github.com/grimmer0125/d4c-queue
投影片 slide: https://slides.com/grimmer/intro_js_ts_task_queuelib_d4c/
演講 video: https://youtu.be/_wxSAEts35w

async in Javascript

Event loop in main thread 一次只會做一個 code block
會從 task queue 拿 code block 執行
JS runtime 內的 UI event 與 network 會塞 task 進 task queue

task 在 V8 中分兩種

  • Macrotask:setTimeout, setIntervial, UI event, XMLHttpRequests
  • Microtask:符合 ECMAScript PromiseJobs 介面的東西
    無論是 browser 還是 nodejs 都是一個 macro task 配上多個 micro task
Select a repo