mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
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
|
||||
// additional thread seems to offer the best performance. More threads make
|
||||
// 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;
|
||||
OutcomesResolver firstHalfResolver = createOutcomesResolver(
|
||||
autoConfigurationClasses, 0, split, autoConfigurationMetadata);
|
||||
|
Loading…
Reference in New Issue
Block a user