mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
Tasks are not allowed to be queued more than once, but it is allowed to queue a Task while it's already running, which means a Task can be executed on two threads in parallel. Tasks detect this and handle it by queueing the Task on its own post-exec queue. That in turn leads to Workers which continually execute the same Task if that Task doesn't create any new Tasks, while other Tasks sit on the Master queue waiting for a Worker to dequeue them. For idle Tasks, we don't want the Task to be rescheduled immediately. We want the idle Task to execute again after every available Task on both the main and idle queues has been executed. Fix these by having each Task reschedule itself on the appropriate queue when it finishes executing. Priority queued Tasks should executed in priority order not just one Task's post-exec queue, but the entire local queue of the TaskConsumer. Fix this by moving the sort into either the TaskConsumer that receives a post-exec queue, if there is one, or into the Task that is created to insert the post-exec queue into a TaskConsumer when one becomes available in the future. Signed-off-by: Zygo Blaxell <bees@furryterror.org>