Skip to content

Instantly share code, notes, and snippets.

@mikebrock
Created July 13, 2011 03:42
Show Gist options
  • Save mikebrock/1079667 to your computer and use it in GitHub Desktop.
Save mikebrock/1079667 to your computer and use it in GitHub Desktop.
public boolean processAll() {
int start;
// brute force FTW
do {
start = processingEntries.size();
List<ProcessingEntry> toRun = new ArrayList<ProcessingEntry>(processingEntries);
for (ProcessingEntry<?> pEntry : toRun) {
if (pEntry.processAllDelegates()) {
processingEntries.remove(pEntry);
}
}
} while (!processingEntries.isEmpty() && processingEntries.size() < start);
// aww man, something's screwed.
if (!processingEntries.isEmpty()) {
// throw a meaningless exception
throw new RuntimeException("unresolved dependences: " + processingEntries);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment