Class WorkManagerImpl
java.lang.Object
com.tangosol.coherence.servlet.commonj.impl.WorkManagerImpl
- All Implemented Interfaces:
WorkManager
This is a simple implementation of a WorkManager that uses a thread pool to
delegate the work to. The number of daemon threads can be configured, but
default is 10.
- Author:
- Torkel Dominique
- See Also:
-
Field Summary
Fields inherited from interface com.tangosol.coherence.servlet.commonj.WorkManager
IMMEDIATE, INDEFINITE
-
Constructor Summary
ConstructorsConstructorDescriptionWorkManagerImpl
(int minThreads, int maxThreads) WorkManagerImpl
(int minThreads, int maxThreads, int maxQueueSize) WorkManagerImpl
(ExecutorService executor) -
Method Summary
-
Constructor Details
-
WorkManagerImpl
public WorkManagerImpl() -
WorkManagerImpl
public WorkManagerImpl(int minThreads, int maxThreads) -
WorkManagerImpl
public WorkManagerImpl(int minThreads, int maxThreads, int maxQueueSize) -
WorkManagerImpl
-
-
Method Details
-
schedule
- Specified by:
schedule
in interfaceWorkManager
- Parameters:
work
- the Work to execute- Returns:
- The workitem representing the asynchronous work. If the Work is serializable then a RemoteWorkItem is always returned.
- Throws:
WorkException
- If queuing this up results in an exception then a WorkException is thrownIllegalArgumentException
- See Also:
-
schedule
public WorkItem schedule(Work work, WorkListener listener) throws WorkException, IllegalArgumentException - Specified by:
schedule
in interfaceWorkManager
- Parameters:
work
- the Work to executelistener
- an optional WorkListener- Returns:
- The workitem representing the asynchronous work. If the Work is serializable then a RemoteWorkItem is always returned.
- Throws:
WorkException
- If queuing this up results in an exception then a WorkException is thrownIllegalArgumentException
- See Also:
-
shutdown
public boolean shutdown(long timeout) Description copied from interface:WorkManager
This method is not part of CommonJ but is needed here since our implementation creates threads that needs to be cleaned up.- Specified by:
shutdown
in interfaceWorkManager
- Parameters:
timeout
- The number of milliseconds until the shutdown is aborted.- Returns:
- true if shutdown was successful, otherwise false.
- See Also:
-