4 ms·
As the API docs note, wait() can be problematic: "If any other promises are created and made to wait while the first promise waits, the first promise’s wait wil
by ionfish 17y ago
As the API docs note, wait() can be problematic: "If any other promises are created and made to wait while the first promise waits, the first promise’s wait will not return until all others return. The benefit of this is a simple implementation and the event loop does not get blocked. Disadvantage is the possibility of situations where the promise stack grows infinitely large because promises keep getting created and keep being told to wait()."
You could get around the lack of naturalness by using something like MethodChain [1] to allow you to write code like this:
posix.rename("/tmp/hello", "/tmp/world")
.stat("/tmp/world")
._(function() {
sys.puts("stats: " + JSON.stringify(this));
});
http://jsclass.jcoglan.com/methodchain.html http://jsclass.jcoglan.com/methodchain.html
- swannodette 17y agoIs there example of how to create this worst case scenario?