generator implement a task scheduler