de.myfoo.commonj.work
Class ResultCollector

java.lang.Object
  extended by de.myfoo.commonj.work.ResultCollector

public final class ResultCollector
extends java.lang.Object

This class collects the results from workers.

Version:
1.0
Author:
Andreas Keldenich

Constructor Summary
ResultCollector(long timeoutMs)
          Creates a new ResultCollector.
 
Method Summary
 void addWorkItem(commonj.work.WorkItem workItem)
          Add a workItem.
 long getTimeout()
           
 void setTimeout(long timeout)
           
 boolean waitForAll()
          Wait for workers/agents to complete.
 java.util.Collection waitForAny()
          Wait for workers/agents to complete.
 void workDone()
          Let the collector know that this work is finished.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultCollector

public ResultCollector(long timeoutMs)
Creates a new ResultCollector.

Parameters:
timeoutMs - timeout in millis
Method Detail

waitForAll

public boolean waitForAll()
                   throws java.lang.InterruptedException
Wait for workers/agents to complete. The Executor calls this method which makes him wait while the workers run.

Returns:
true if all items are done in time.
Throws:
java.lang.InterruptedException - If work got interrupted

waitForAny

public java.util.Collection waitForAny()
                                throws java.lang.InterruptedException
Wait for workers/agents to complete. The Executor calls this method which makes him wait while the workers run.

Returns:
true if the execution timed out
Throws:
java.lang.InterruptedException - If work got interrupted

workDone

public void workDone()
Let the collector know that this work is finished.


addWorkItem

public void addWorkItem(commonj.work.WorkItem workItem)
Add a workItem.


getTimeout

public long getTimeout()
Returns:
Returns the timeout.

setTimeout

public void setTimeout(long timeout)
Parameters:
timeout - The timeout to set.