Skip to content

Commit

Permalink
Only add hold when results are closed
Browse files Browse the repository at this point in the history
  • Loading branch information
hollingsworthd committed Apr 13, 2015
1 parent 3d7b5dc commit d082c76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 9 additions & 5 deletions api/src/com/screenslicer/api/datatype/Result.java
Expand Up @@ -173,6 +173,10 @@ public void close() {
}
}

public boolean isClosed() {
return key != null;
}

public void remove() {
try {
if (key != null) {
Expand All @@ -184,16 +188,16 @@ public void remove() {
}
}

public static boolean hasHold() {
public static boolean hasHolds() {
return holdCount.get() != 0;
}

public static void removeHold(int num) {
holdCount.addAndGet(-1 * num);
public static void removeHold() {
holdCount.decrementAndGet();
}

public static void addHold(int num) {
holdCount.addAndGet(num);
public static void addHold() {
holdCount.incrementAndGet();
}

public boolean open() {
Expand Down
6 changes: 5 additions & 1 deletion core/src/com/screenslicer/core/scrape/Scrape.java
Expand Up @@ -843,7 +843,11 @@ public static List<Result> scrape(Query query, Request req) {
ret = scrape(query, req, 0, i + 1 == MAX_INIT, media, cache, myThread);
Log.info("Scrape finished");
List<Result> searchResults = ret.drain();
Result.addHold(searchResults.size());
for (Result result : searchResults) {
if (result.isClosed()) {
Result.addHold();
}
}
return searchResults;
} catch (Browser.Fatal f) {
Log.exception(f);
Expand Down

0 comments on commit d082c76

Please sign in to comment.