W3C home > Mailing lists > Public > www-tag@w3.org > January 2014

Re: [promises] Guidance on the usage of promises for API developers

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 14 Jan 2014 10:55:25 -0500
Message-ID: <52D55DED.4090108@mit.edu>
To: Domenic Denicola <domenic@domenicdenicola.com>, Takeshi Yoshino <tyoshino@google.com>, "www-tag@w3.org" <www-tag@w3.org>
CC: public-webapps <public-webapps@w3.org>
On 1/14/14 10:44 AM, Domenic Denicola wrote:
> I do want to clarify that I want to avoid explicitly queuing needless tasks, which then themselves go and perform asynchronous actions. Instead, just perform the asynchronous action, and use the promise microtask queue to the deliver the results.

That's actually an interesting question.  Right now, the deal with task 
queues is that certain operations explicitly freeze some task queues but 
not others.  Thus the choice of task queue for a task determines what 
things it might end up blocking on (thing alert() and the like).

What I think is really be desired in some cases is to perform the async 
action and when it's done insert a task into the right task queue that 
resolves the promise.  If I understand correctly how microtasks work, in 
that situation the promise callbacks will be invoked as soon as the task 
finishes.

Note that this is how I expect UAs to actually implement this under the 
hood, for what it's worth, since reaching across thread boundaries to 
resolve a promise is pretty suboptimal (suddenly need locks or whatnot), 
so chances are they'll pass messages that when received resolve promises...

-Boris
Received on Tuesday, 14 January 2014 15:56:06 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:33:23 UTC