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

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