Polish "Check for multiple processors in OnClassCondition"

Closes gh-16115
pull/16225/head
Stephane Nicoll 6 years ago
parent a96a79ea45
commit 4d73211c3a

@ -46,25 +46,20 @@ class OnClassCondition extends FilteringSpringBootCondition {
@Override
protected final ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses,
AutoConfigurationMetadata autoConfigurationMetadata) {
// 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
// Split the work and perform half in a background thread if more than one
// processor is available. 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(
OutcomesResolver outcomesResolver = new StandardOutcomesResolver(
autoConfigurationClasses, 0, autoConfigurationClasses.length,
autoConfigurationMetadata);
autoConfigurationMetadata, getBeanClassLoader());
return outcomesResolver.resolveOutcomes();
}
}
private ConditionOutcome[] resolveOutcomesThreaded(String[] autoConfigurationClasses,
AutoConfigurationMetadata autoConfigurationMetadata) {

Loading…
Cancel
Save