org.apache.tuscany.sca.core.work
Class ThreadPoolWorkManager

java.lang.Object
  extended by org.apache.tuscany.sca.core.work.ThreadPoolWorkManager

public class ThreadPoolWorkManager
extends java.lang.Object

A thread-pool based implementation for the JSR-237 work manager.

This implementation supports only local work.

TODO Elaborate the implementation.


Constructor Summary
ThreadPoolWorkManager(int threadPoolSize)
          Initializes the thread-pool.
 
Method Summary
 void destroy()
           
 WorkItem schedule(Work work)
          Schedules a unit of work asynchronously.
 WorkItem schedule(Work work, WorkListener workListener)
          Schedules a unit of work asynchronously.
 boolean waitForAll(java.util.Collection works, long timeout)
          Wait for all the specified units of work to finish.
 java.util.Collection waitForAny(java.util.Collection works, long timeout)
          Wait for any of the specified units of work to finish.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadPoolWorkManager

public ThreadPoolWorkManager(int threadPoolSize)
Initializes the thread-pool.

Parameters:
threadPoolSize - Thread-pool size.
Throws:
java.lang.IllegalArgumentException - if threadPoolSize < 1
Method Detail

schedule

public WorkItem schedule(Work work)
                  throws java.lang.IllegalArgumentException
Schedules a unit of work asynchronously.

Parameters:
work - Work that needs to be scheduled.
Returns:
Work Work item representing the asynchronous work
Throws:
java.lang.IllegalArgumentException

schedule

public WorkItem schedule(Work work,
                         WorkListener workListener)
                  throws java.lang.IllegalArgumentException
Schedules a unit of work asynchronously.

Parameters:
work - Work that needs to be scheduled.
workListener - Work listener for callbacks.
Returns:
Work Work item representing the asynchronous work
Throws:
java.lang.IllegalArgumentException

waitForAll

public boolean waitForAll(java.util.Collection works,
                          long timeout)
Wait for all the specified units of work to finish.

Parameters:
works - Units of the work that need to finish.
timeout - Timeout for waiting for the units of work to finish.

waitForAny

public java.util.Collection waitForAny(java.util.Collection works,
                                       long timeout)
Wait for any of the specified units of work to finish.

Parameters:
works - Units of the work that need to finish.
timeout - Timeout for waiting for the units of work to finish.

destroy

public void destroy()