Message Priority: The Naive Approach (3 of 3)
- The following problems occur:
- Both functions use after 0 to avoid stalling; result is message polling
- Both functions consume CPU even when the queue is empty
- Every failed scan for a priority message visits every message in the queue
- If only normal messages received, requires N! + N message scans
- OK... maybe if we unload the queue before processing?
- Process the list of priority messages first
- Handle the normal messages next
- Loop and collect more