File tree Expand file tree Collapse file tree 1 file changed +20
-13
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -1000,19 +1000,26 @@ static void setNextJob(Job *job, Job* next) {
1000
1000
enum { NumPriorityBuckets = 5 };
1001
1001
1002
1002
static int getPriorityIndex (JobPriority priority) {
1003
- switch (priority) {
1004
- case JobPriority::UserInteractive:
1005
- return 0 ;
1006
- case JobPriority::UserInitiated:
1007
- return 1 ;
1008
- case JobPriority::Unspecified:
1009
- assert (false );
1010
- case JobPriority::Default:
1011
- return 2 ;
1012
- case JobPriority::Utility:
1013
- return 3 ;
1014
- case JobPriority::Background:
1015
- return 4 ;
1003
+ // Any unknown priorities will be rounded up to a known one.
1004
+ // Priorities higher than UserInteractive are clamped to UserInteractive.
1005
+ // Jobs of unknown priorities will end up in the same bucket as jobs of a
1006
+ // corresponding known priority. Within the bucket they will be sorted in FIFO
1007
+ // order.
1008
+ if (priority > JobPriority::UserInitiated) {
1009
+ // UserInteractive and higher
1010
+ return 0 ;
1011
+ } else if (priority > JobPriority::Default) {
1012
+ // UserInitiated
1013
+ return 1 ;
1014
+ } else if (priority > JobPriority::Utility) {
1015
+ // Default
1016
+ return 2 ;
1017
+ } else if (priority > JobPriority::Background) {
1018
+ // Utility
1019
+ return 3 ;
1020
+ } else {
1021
+ // Background and lower
1022
+ return 4 ;
1016
1023
}
1017
1024
}
1018
1025
You can’t perform that action at this time.
0 commit comments