Package org.jboss.util.threadpool
Class RunnableTaskWrapper
- java.lang.Object
-
- org.jboss.util.threadpool.RunnableTaskWrapper
-
- All Implemented Interfaces:
java.lang.Runnable
,TaskWrapper
public class RunnableTaskWrapper extends java.lang.Object implements TaskWrapper
Makes a runnable a task.- Version:
- $Revision$
-
-
Field Summary
Fields Modifier and Type Field Description private long
completionTimeout
The completion timeoutprivate static org.jboss.logging.Logger
log
The logprivate java.lang.Runnable
runnable
The runnableprivate java.lang.Thread
runThread
private boolean
started
private long
startTimeout
The start timeout
-
Constructor Summary
Constructors Constructor Description RunnableTaskWrapper(java.lang.Runnable runnable)
Create a new RunnableTaskWrapperRunnableTaskWrapper(java.lang.Runnable runnable, long startTimeout, long completeTimeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptTask()
The task has been acceptedlong
getTaskCompletionTimeout()
The time before the task must be completedint
getTaskPriority()
The priority of the tasklong
getTaskStartTimeout()
The time before the task must be acceptedint
getTaskWaitType()
Get the type of waitboolean
isComplete()
Is the task complete.void
rejectTask(java.lang.RuntimeException t)
The task has been rejectedvoid
run()
void
stopTask()
Invoked by the threadpool when it wants to stop the taskvoid
waitForTask()
Wait according the wait type
-
-
-
Field Detail
-
log
private static final org.jboss.logging.Logger log
The log
-
runnable
private java.lang.Runnable runnable
The runnable
-
started
private boolean started
-
runThread
private java.lang.Thread runThread
-
startTimeout
private long startTimeout
The start timeout
-
completionTimeout
private long completionTimeout
The completion timeout
-
-
Constructor Detail
-
RunnableTaskWrapper
public RunnableTaskWrapper(java.lang.Runnable runnable)
Create a new RunnableTaskWrapper- Parameters:
runnable
- the runnable- Throws:
java.lang.IllegalArgumentException
- for a null runnable
-
RunnableTaskWrapper
public RunnableTaskWrapper(java.lang.Runnable runnable, long startTimeout, long completeTimeout)
-
-
Method Detail
-
getTaskWaitType
public int getTaskWaitType()
Description copied from interface:TaskWrapper
Get the type of wait- Specified by:
getTaskWaitType
in interfaceTaskWrapper
- Returns:
- the wait type
-
getTaskPriority
public int getTaskPriority()
Description copied from interface:TaskWrapper
The priority of the task- Specified by:
getTaskPriority
in interfaceTaskWrapper
- Returns:
- the task priority
-
getTaskStartTimeout
public long getTaskStartTimeout()
Description copied from interface:TaskWrapper
The time before the task must be accepted- Specified by:
getTaskStartTimeout
in interfaceTaskWrapper
- Returns:
- the start timeout
-
getTaskCompletionTimeout
public long getTaskCompletionTimeout()
Description copied from interface:TaskWrapper
The time before the task must be completed- Specified by:
getTaskCompletionTimeout
in interfaceTaskWrapper
- Returns:
- the completion timeout
-
acceptTask
public void acceptTask()
Description copied from interface:TaskWrapper
The task has been accepted- Specified by:
acceptTask
in interfaceTaskWrapper
-
rejectTask
public void rejectTask(java.lang.RuntimeException t)
Description copied from interface:TaskWrapper
The task has been rejected- Specified by:
rejectTask
in interfaceTaskWrapper
- Parameters:
t
- any error associated with the rejection
-
stopTask
public void stopTask()
Description copied from interface:TaskWrapper
Invoked by the threadpool when it wants to stop the task- Specified by:
stopTask
in interfaceTaskWrapper
-
waitForTask
public void waitForTask()
Description copied from interface:TaskWrapper
Wait according the wait type- Specified by:
waitForTask
in interfaceTaskWrapper
-
isComplete
public boolean isComplete()
Description copied from interface:TaskWrapper
Is the task complete.- Specified by:
isComplete
in interfaceTaskWrapper
- Returns:
- true if compelet, false otherwise
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
-