COSCUP x RubyConf TW 2021

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

演講摘要

你有聽過 JavaScript 是單一執行緒的語言嗎? 你知道 JavaScript 的 async 的原理嗎? 你知道什麼時候會需要控制 concurrency 的情形嗎? 本演講除了會為你一一解答外,還會帶著你走一遍如何實作出一個開源的 task queue library,以及如何在 TypeScript 中實作出其他語言 (e.g. Java) 的 @synchronized decorator.

大綱:

  1. 介紹 JavaScript 的 async, concurrency - 4 min
  2. 介紹為何要打造 task queue library - 4 min
  3. 實際講解程式碼跟範例 - 17 min
    • 使用 @synchronized, @concurrent 在 method 上
    • 一般 async/promising return/sync function 型式的使用方法
    • 講解程式碼
  4. Q & A - 5min

英文演講摘要

Have you ever heard that JavaScript is a single thread language? Do you know what is async in JavaScript? Do you know when you need to control the concurrency situation in your code? This talk will give you a guide on how to make an open-source task queue library, and how to use TypeScript to make a @synchronized decorator often seen in other languages, like Java.

Outline:

  1. Introduction what is async and concurrency in JavaScript - 4 min
  2. Introduce why do we need a task queue library - 4 min
  3. Go through the code and its example - 17 min
    • use @synchronized, @concurrent on method
    • use async function, promising-returning function, syn function into queue
    • go through the code
  4. Q & A - 5 min
Grimmer