A priority equal-opportunity threadpool that consists of the following sections in its backing queue.
All tasks in “preemptive queue” will be executed FIFO.
All tasks in “round robin queue” will be executed Round Robin if preemptive queue is empty.
All tasks in “can wait queue” will be executed FIFO if both preemptive and round robin queue are empty.
This is to guarantee an overall priority of different categories of tasks. Tasks that are critical to the system are allowed to preemptively run with minimum wait time. Application tasks are given fair chances to run with as little wait time as possible. Non-critical and long running tasks are only run when the system is idle.
Round Robin Section consists of multiple priority queue(s) for every use case.
Algorithm: Thread pool runner keeps a count of running threads for every use case and when there are idle thread, and no new task in the preemptive queue, a task from the round robin queue will be chosen to run. The candidate will be picked from all use case queues that have pending tasks with round robin fashion. Fairness among all use cases is guarenteed, this implementation provides equal opportunity for tasks from different use cases to be run.
Each use case queue is a priority queue by itself; tasks are sorted based on its priority specified by its submitter.
Anonymous