Javascript API to explicitly add micro tasks or macro tasks
<p>From my global understanding of how javascript virtual machines works, i can clearly see that the concept of <strong>micro task / macro task</strong> play a big role.</p>

<hr>

<p>Here is what i understand about that:  </p>

<ul>
<li>A VM 'turn' is the fact of pulling ONE macro task out of the VM macro task queue, and execute it.</li>
<li>During a VM turn, micro tasks can be added to the micro tasks queue of the current macro task.</li>
<li>Micro tasks can push other micro tasks to the micro tasks queue of the current macro task.</li>
<li>A VM turn will end when the micro task queue is empty.</li>
</ul>

<hr>

<p>And here is the point of my question:</p>

<p><strong>Why there is no clear API to manipulate those two queues.</strong></p>

<p>Something like</p>

<ul>
<li><code>pushToMacroTask( function )</code></li>
<li><code>pushToMicroTask( function )</code></li>
</ul>

<p>Actually it seams like the only way to manipulate those queue is to use <code>setTimeout()</code> to add tasks to the macro tasks queue and <code>Promises</code> to add tasks to the micro tasks queue...  </p>

<p>I'm ok with that but this does not give us a meaningfull API, don't you think ?</p>

<p>Is this concept supposed to remain 'hidden' to JS dev and only used in some hacky situations ?</p>

<p>Do you know if there is any W3C spec around that subject ?</p>

<p>Does all VM engines implement this concept the same way ?</p>

<p>I'd be glad to ear stories and opinions about that.</p>

<p>Thanks !</p>