Polish "Check for multiple processors in OnClassCondition"

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

@ -46,26 +46,21 @@ class OnClassCondition extends FilteringSpringBootCondition {
@Override @Override
protected final ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses, protected final ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses,
AutoConfigurationMetadata autoConfigurationMetadata) { AutoConfigurationMetadata autoConfigurationMetadata) {
// Split the work and perform half in a background thread. Using a single // Split the work and perform half in a background thread if more than one
// additional thread seems to offer the best performance. More threads make // processor is available. Using a single additional thread seems to offer the
// things worse // best performance. More threads make things worse.
if (Runtime.getRuntime().availableProcessors() > 1) { if (Runtime.getRuntime().availableProcessors() > 1) {
return resolveOutcomesThreaded(autoConfigurationClasses, return resolveOutcomesThreaded(autoConfigurationClasses,
autoConfigurationMetadata); autoConfigurationMetadata);
} }
else { else {
return resolveOutcomes(autoConfigurationClasses, autoConfigurationMetadata); OutcomesResolver outcomesResolver = new StandardOutcomesResolver(
autoConfigurationClasses, 0, autoConfigurationClasses.length,
autoConfigurationMetadata, getBeanClassLoader());
return outcomesResolver.resolveOutcomes();
} }
} }
private ConditionOutcome[] resolveOutcomes(String[] autoConfigurationClasses,
AutoConfigurationMetadata autoConfigurationMetadata) {
OutcomesResolver outcomesResolver = createOutcomesResolver(
autoConfigurationClasses, 0, autoConfigurationClasses.length,
autoConfigurationMetadata);
return outcomesResolver.resolveOutcomes();
}
private ConditionOutcome[] resolveOutcomesThreaded(String[] autoConfigurationClasses, private ConditionOutcome[] resolveOutcomesThreaded(String[] autoConfigurationClasses,
AutoConfigurationMetadata autoConfigurationMetadata) { AutoConfigurationMetadata autoConfigurationMetadata) {
int split = autoConfigurationClasses.length / 2; int split = autoConfigurationClasses.length / 2;

Loading…
Cancel
Save