int parallelMethods = allGroups.get(Type.METHODS);
int poolSize = totalPoolSize();
ExecutorService commonPool = splitPool || poolSize == 0 ? null : createPool(poolSize);
master = createMaster(commonPool, poolSize);
ParentRunner suiteSuites = wrapRunners( suites );
if ( suiteSuites != null )
{
// a scheduler for parallel suites
if ( commonPool != null && parallelSuites > 0 )
{
Balancer balancer = BalancerFactory.createBalancerWithFairness( parallelSuites );
suiteSuites.setScheduler( createScheduler( null, commonPool, true, balancer ) );
}
else
{
suiteSuites.setScheduler( createScheduler( parallelSuites ) );
}
}
// schedulers for parallel classes
ParentRunner suiteClasses = wrapRunners( classes );
ArrayList<ParentRunner> allSuites = new ArrayList<ParentRunner>( suites );
allSuites.addAll( nestedSuites );
if ( suiteClasses != null )
{
allSuites.add( suiteClasses );
}
if ( !allSuites.isEmpty() )
{
setSchedulers( allSuites, parallelClasses, commonPool );
}
// schedulers for parallel methods
ArrayList<ParentRunner> allClasses = new ArrayList<ParentRunner>( classes );
allClasses.addAll( nestedClasses );
if ( !allClasses.isEmpty() )
{
setSchedulers( allClasses, parallelMethods, commonPool );
}
// resulting runner for Computer#getSuite() scheduled by master scheduler
ParentRunner all = createFinalRunner( suiteSuites, suiteClasses );
all.setScheduler( master );
return all;
}