Add support for an advanced task scheduler managed by the application.

Having `do_` call `shift` and then use a dummy `function() {}` followed by calling `unshift` here feels more complicated than this needs to be.  It also creates the potential for infinite loops, if not already, then a small refactoring away.  Can you rework this pattern?