Check for multiple processors in OnClassCondition
See gh-16115
This commit is contained in:
		
							parent
							
								
									9da20b7e52
								
							
						
					
					
						commit
						a96a79ea45
					
				|  | @ -49,6 +49,25 @@ class OnClassCondition extends FilteringSpringBootCondition { | ||||||
| 		// Split the work and perform half in a background thread. Using a single | 		// Split the work and perform half in a background thread. Using a single | ||||||
| 		// additional thread seems to offer the best performance. More threads make | 		// additional thread seems to offer the best performance. More threads make | ||||||
| 		// things worse | 		// things worse | ||||||
|  | 		if (Runtime.getRuntime().availableProcessors() > 1) { | ||||||
|  | 			return resolveOutcomesThreaded(autoConfigurationClasses, | ||||||
|  | 					autoConfigurationMetadata); | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			return resolveOutcomes(autoConfigurationClasses, autoConfigurationMetadata); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private ConditionOutcome[] resolveOutcomes(String[] autoConfigurationClasses, | ||||||
|  | 			AutoConfigurationMetadata autoConfigurationMetadata) { | ||||||
|  | 		OutcomesResolver outcomesResolver = createOutcomesResolver( | ||||||
|  | 				autoConfigurationClasses, 0, autoConfigurationClasses.length, | ||||||
|  | 				autoConfigurationMetadata); | ||||||
|  | 		return outcomesResolver.resolveOutcomes(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private ConditionOutcome[] resolveOutcomesThreaded(String[] autoConfigurationClasses, | ||||||
|  | 			AutoConfigurationMetadata autoConfigurationMetadata) { | ||||||
| 		int split = autoConfigurationClasses.length / 2; | 		int split = autoConfigurationClasses.length / 2; | ||||||
| 		OutcomesResolver firstHalfResolver = createOutcomesResolver( | 		OutcomesResolver firstHalfResolver = createOutcomesResolver( | ||||||
| 				autoConfigurationClasses, 0, split, autoConfigurationMetadata); | 				autoConfigurationClasses, 0, split, autoConfigurationMetadata); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue