mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge pull request #16115 from JWThewes
* pr/16115: Polish "Check for multiple processors in OnClassCondition" Check for multiple processors in OnClassCondition
This commit is contained in:
commit
210c51e31c
@ -46,9 +46,23 @@ 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 {
|
||||
OutcomesResolver outcomesResolver = new StandardOutcomesResolver(
|
||||
autoConfigurationClasses, 0, autoConfigurationClasses.length,
|
||||
autoConfigurationMetadata, getBeanClassLoader());
|
||||
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