Skip to content

Instantly share code, notes, and snippets.

@DannyDelott
Created February 14, 2015 23:56
Show Gist options
  • Save DannyDelott/89ae34b7df5f8341cb75 to your computer and use it in GitHub Desktop.
Save DannyDelott/89ae34b7df5f8341cb75 to your computer and use it in GitHub Desktop.
Process a buffer to find Vine videos
private static void processCurrentBuffer() {
// Does nothing if the current buffer is already processing or
// if it contains fewer elements than the minimum buffer size.
if ((currentBufferId == 1 && (buffer1.isProcessing() || buffer1
.getTweets().size() < MIN_BUFFER_SIZE)) ||
(currentBufferId == 2 && (buffer2.isProcessing() || buffer2
.getTweets().size() < MIN_BUFFER_SIZE))) {
return;
}
// Otherwise, begin processing.
try {
switch (currentBufferId) {
case 1:
buffer1.setProcessing(true);
currentBufferId = 2;
Thread t1 = new Thread(new ProcessingThread(buffer1,
duplicateUrls, finishListener));
t1.start();
break;
case 2:
buffer2.setProcessing(true);
currentBufferId = 1;
Thread t2 = new Thread(new ProcessingThread(buffer2,
duplicateUrls, finishListener));
t2.start();
break;
}
} catch (Throwable t) {
t.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment