int numCompUnitRemoved = 0;
workSet.addAll(compilationUnits);
while (workSet.size() > 0)
{
final ICompilationUnit currentUnit = workSet.iterator().next();
workSet.remove(currentUnit);
if (visitedSet.add(currentUnit))
{
//Increment num of the comp units removed from the workset,
//so that we can calculate the total number of compilation units.
//The reason we only increment it in this if block is that if
//we don't hit in this if block, it means that we had removed
//the same compilation unit before anyways, so we already
//have taken it into account.
numCompUnitRemoved++;
currentUnit.startBuildAsync(getTargetType());
final DirectDependencies currentUnitDependencies = getDirectDependencies(currentUnit);
final Iterable<ICompilationUnit> newCompilationUnitWork = currentUnitDependencies.dependencies;
Iterables.addAll(problems, currentUnitDependencies.problems);