First of all, have you considered implementing a Priority Queue? This will allow you to have just one queue, which automatically arranges items in it based on priority - this will allow you to just have one simple listener to get the Next Item from the queue, and rely on the priority to ensure the Next Item is always the highest priority available. There are many implementations of it, including one here on CodeReview.SE one here on CodeReview.SE I found in the "Related" sidebar. Another advantage over your queue-per-priority is that you can have more complex prioritization logic, rather than just base it on one field.
However, if you wish to stick your your (conceptually simpler to grok) multiple queues, you can still make the code cleaner and more generic by replacing the variable-for-each-queue with a SortedList<ThreadPriority,ConcurrentQueue>
- have the queues by keyed by priority, and instead of having a big switch/case block to determine the current queue, you can iterate on the Keys, which are sorted.
First of all, have you considered implementing a Priority Queue? This will allow you to have just one queue, which automatically arranges items in it based on priority - this will allow you to just have one simple listener to get the Next Item from the queue, and rely on the priority to ensure the Next Item is always the highest priority available. There are many implementations of it, including one here on CodeReview.SE I found in the "Related" sidebar. Another advantage over your queue-per-priority is that you can have more complex prioritization logic, rather than just base it on one field.
However, if you wish to stick your your (conceptually simpler to grok) multiple queues, you can still make the code cleaner and more generic by replacing the variable-for-each-queue with a SortedList<ThreadPriority,ConcurrentQueue>
- have the queues by keyed by priority, and instead of having a big switch/case block to determine the current queue, you can iterate on the Keys, which are sorted.
First of all, have you considered implementing a Priority Queue? This will allow you to have just one queue, which automatically arranges items in it based on priority - this will allow you to just have one simple listener to get the Next Item from the queue, and rely on the priority to ensure the Next Item is always the highest priority available. There are many implementations of it, including one here on CodeReview.SE I found in the "Related" sidebar. Another advantage over your queue-per-priority is that you can have more complex prioritization logic, rather than just base it on one field.
However, if you wish to stick your your (conceptually simpler to grok) multiple queues, you can still make the code cleaner and more generic by replacing the variable-for-each-queue with a SortedList<ThreadPriority,ConcurrentQueue>
- have the queues by keyed by priority, and instead of having a big switch/case block to determine the current queue, you can iterate on the Keys, which are sorted.
First of all, have you considered implementing a Priority Queue? This will allow you to have just one queue, which automatically arranges items in it based on priority - this will allow you to just have one simple listener to get the Next Item from the queue, and rely on the priority to ensure the Next Item is always the highest priority available. There are many implementations of it, including one here on CodeReview.SE I found in the "Related" sidebar. Another advantage over your queue-per-priority is that you can have more complex prioritization logic, rather than just base it on one field.
However, if you wish to stick your your (conceptually simpler to grok) multiple queues, you can still make the code cleaner and more generic by replacing the variable-for-each-queue with a SortedList<ThreadPriority,ConcurrentQueue>
- have the queues by keyed by priority, and instead of having a big switch/case block to determine the current queue, you can iterate on the Keys, which are sorted.