|
Why don't you like async/await? 8 years ago I wrote a npm package that turned code that looks like this: tcp.send("syn", function(syn) {
console.log("received", syn);
tcp.send("syn-ack", function(synack) {
console.log("received", synack);
tcp.send("ack", function(ack) {
console.log("received", ack);
});
});
});
into this: seq([tcp, console], function(tcp, console) {
var syn = {}; var synack = {}; var ack = {};
tcp.send("syn", this(syn));
console.log("received %s", syn);
tcp.send("syn-ack", this(synack));
console.log("received %s", synack);
tcp.send("ack", this(ack));
console.log("received %s", ack);
});
it was never ready for production use, but it showed that synchronous code illusion can be created from callbacks.How would you prefer to write asynchronous code? How does Loom handle resource starvation problem? If a thread puts a while (true) {} in there somewhere, can that thread be preempted away from that kernel thread? |
If you put while (true) { } in an asynchronous function, wouldn't you also have a resource starvation problem? For what it's worth though, Loom threads are planned to be fully preemptible.