Skip to content

Commit

Permalink
DidYouMean: as I moved to only 8 consumer and 4 producer threads, I r…
Browse files Browse the repository at this point in the history
…emoved poison pills as it does not make sense anymore - threads are interrupted directly. Having a consumer thread per test case just didn't make sense either (see svn 6070) due to the massive overhead.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6072 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
apfelmaennchen committed Jun 14, 2009
1 parent c3c4dd0 commit 39779e4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions source/de/anomic/tools/DidYouMean.java
Expand Up @@ -63,17 +63,31 @@ public Set<String> getSuggestion(final String word) {
}

// check if timeout has been reached
while(((System.currentTimeMillis()-startTime) < TIMEOUT) && queue.size()>0) {
// consume more ...
boolean cont = false;
while(((System.currentTimeMillis()-startTime) < TIMEOUT)) {
if(queue.size()==0) {
// check if at least one producers is still running
for (int i=0; i<producers.length; i++) {
if(producers[i].isAlive())
cont = true;
}
if(!cont) break;
}
}

// put "poison pill" for each consumer thread
// interupt all consumer threads
for (int i=0; i<consumers.length; i++) {
consumers[i].interrupt();
}

/* put "poison pill" for each consumer thread
for (int i=0; i<consumers.length; i++) {
try {
queue.put("\n");
} catch (InterruptedException e) {
}
}
*/

// interupt all remaining producer threads
for (int i=0; i<producers.length; i++) {
Expand All @@ -82,7 +96,7 @@ public Set<String> getSuggestion(final String word) {

this.set.remove(word.toLowerCase());
Log.logInfo("DidYouMean", "found "+this.set.size()+" terms; execution time: "
+(System.currentTimeMillis()-startTime)+"ms"+ (queue.size()>0?"(timed out)":""));
+(System.currentTimeMillis()-startTime)+"ms"+ " - remaining queue size: "+queue.size());

return this.set;

Expand Down

0 comments on commit 39779e4

Please sign in to comment.