2 ms·
Concurrency is just the ability to handle multiple tasks at the same time, to use my quickly googled definition. JavaScript already supports concurrency, e.g.
by joeycumines 3y ago
Concurrency is just the ability to handle multiple tasks at the same time, to use my quickly googled definition.
JavaScript already supports concurrency, e.g. handling more than one HTTP request concurrently, despite the runtime being single-threaded in nature.
Also provided by JavaScript is the ability to fork and join with other asynchronous tasks, e.g. using `Promise.all` to wait for multiple HTTP requests to complete.
The purpose of `ts-chan` is to make it easier to coordinate concurrent operations, via communication, which definitely isn't something JavaScript makes easy.
So part of this is addressing usability issues, and providing necessary boilerplate.
I've modelled most of that after Go's channels.
Another is providing a mitigation for a common gotcha (well, it's gotten me), when attempting to implement behavior that involves multiple independent asynchronous operations, communicating with one another. Specifically, JS has a "microtask queue", an optimisation I believe was created to power async/await. Details / links to MDN here: https://github.com/joeycumines/ts-chan#the-microtask-queue-a-footgun https://github.com/joeycumines/ts-chan#the-microtask-queue-a...
- deleted 3y ago[deleted]
- thecopy 3y agoThanks. I was confused by the terminology. I thought Concurrency = Parallelism, however i realise now that concurrency does not mean that the code is being executed at the same time (not considering waiting for I/O as "executing") while Parallelism means executing at the same time.