Please enable JavaScript.
Coggle requires JavaScript to display documents.
20190829_Queues & Thread (Links (https://www.youtube.com/watch?v=OFnSq…
20190829_Queues & Thread
Links
https://www.youtube.com/watch?v=OFnSq_0_Pyc
https://www.youtube.com/watch?v=8aGhZQkoFbQ
https://www.youtube.com/watch?v=u1kqx6AenYw
https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
https://codeburst.io/promises-for-the-web-worker-9311b7831733
https://blog.bitsrc.io/microtask-and-macrotask-a-hands-on-approach-5d77050e2168
https://blog.risingstack.com/writing-a-javascript-framework-execution-timing-beyond-settimeout/
https://hackernoon.com/understanding-js-the-event-loop-959beae3ac40
Constraints
DOM Blocking
Everything is run in the main thread (UI) by default
Big calculation causes UI to freeze
JS is single threaded language
https://www.sitepoint.com/avoiding-dom-blocking/
Event loop algorithm is complex
Micro Tasks cannot be stopped and causes freeze
JS Engine
Stack
Heap
Task queues
Macro Tasks
Micro Tasks
Event Loop
UI rendering
Workers
https://www.sitepoint.com/javascript-web-workers/
Shared Web Workers
Worklet
Web Workers
Service Workers
CanIUse
https://caniuse.com/#feat=serviceworkers
https://caniuse.com/#search=Web%20workers
https://caniuse.com/#search=Worklet
https://caniuse.com/#search=Shared%20web%20workers
https://bitsofco.de/web-workers-vs-service-workers-vs-worklets/
These solutions unblock the UI thread but have dedicated scope, can't access DOM, and have a memory cost in creation of a parallel thread. It need to be terminated to give back memory, and better not to launch too many in parallel.