| This is interesting. Correct me if I don't understand is this only concurrent with respect to IO is that right? If you run a IO operation or network call (fetch api) in those promises, those shall be concurrent with the CPU execution of your Javascript? I think async/await is a great primitive. I've been working on implementing a async/await switch statement based state machine* in Java for multithreaded async/await. I want to handle the scheduling of multiple promises eagerly, so when you call async task1(); async task2(); async task3(); it schedules them all independently on different threads. * if you've used protothreads in C, this is what it is similar to. To do interleaved concurrency in Javascript, you could do the same pattern (switch based state machine) or do my concurrent looping approach. You break up your long CPU task into lots of microtasks and switch between them concurrently with a switch statement. You switch between tasks with a scheduler loop, so you do a bit of work on each task independently. It's concurrent but not parallel. here's my writeup of concurrent loops which takes arbitrarily nested loops and turns them into an iterator
https://github.com/samsquire/ideas4#133-concurrent-loops---l... here's my java state machine of multithreaded async/await in Java, that could be adapted to Javascript except it wouldn't be parallel. https://github.com/samsquire/multiversion-concurrency-contro... |