org.embl.ebi.escience.scuflui.workbench
Class ScavengerHelperThreadPool

java.lang.Object
  extended by org.embl.ebi.escience.scuflui.workbench.ScavengerHelperThreadPool

public class ScavengerHelperThreadPool
extends java.lang.Object

A thread pool that handles a collection of Scavenger threads (for URLBasedScavengers) The pool ensures that there is a maximum number of concurrent threads, and maintains a waiting list for those threads that cannot yet be started. Each time getCompleted is called and the completed Scavengers are returned, waiting threads are moved to the active list and started. The pool is complete when all completed Scavengers have been return through getComplete, and isEmpty returns true

Author:
Stuart Owen

Constructor Summary
ScavengerHelperThreadPool()
           
 
Method Summary
 void addScavengerHelper(ScavengerHelper helper)
          Adds a new scavenger helper, and creates a thread for it to load the default scavengers.
 void addScavengerHelperForModel(ScavengerHelper helper, ScuflModel theModel)
          Scavengers over a ScuflModel for processors that are understood by the scavenger helper.
 void addThread(org.embl.ebi.escience.scuflui.workbench.ScavengerHelperThreadPool.ScavengerHelperThread thread)
           
 java.util.Set<Scavenger> getCompleted()
          Returns a Set of Scavengers that have completed their initialisation
 boolean isEmpty()
          Returns true if all threads have completed and have had their results retrieved via getCompleted
 int remaining()
          Returns the total number of threads waiting to complete, or waiting to be removed via getCompleted.
 int waiting()
          Returns the number of threads waiting to start
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScavengerHelperThreadPool

public ScavengerHelperThreadPool()
Method Detail

addThread

public void addThread(org.embl.ebi.escience.scuflui.workbench.ScavengerHelperThreadPool.ScavengerHelperThread thread)

waiting

public int waiting()
Returns the number of threads waiting to start

Returns:

remaining

public int remaining()
Returns the total number of threads waiting to complete, or waiting to be removed via getCompleted. This will be zero when all threads have finished and have had their results retrieved.

Returns:

addScavengerHelper

public void addScavengerHelper(ScavengerHelper helper)
Adds a new scavenger helper, and creates a thread for it to load the default scavengers. The thread will either be started immediately, or placed on the waiting queue.

Parameters:
helper -

addScavengerHelperForModel

public void addScavengerHelperForModel(ScavengerHelper helper,
                                       ScuflModel theModel)
Scavengers over a ScuflModel for processors that are understood by the scavenger helper. The thread will either be started immediately, or placed on the waiting queue.

Parameters:
helper -
theModel -

getCompleted

public java.util.Set<Scavenger> getCompleted()
Returns a Set of Scavengers that have completed their initialisation

Returns:

isEmpty

public boolean isEmpty()
Returns true if all threads have completed and have had their results retrieved via getCompleted

Returns: