Implement loop_scheduler's run_for() and run_until() functions.