Package jadex.commons.future
Class ThreadSuspendable
- java.lang.Object
-
- jadex.commons.future.ThreadLocalTransferHelper
-
- jadex.commons.future.ThreadSuspendable
-
- All Implemented Interfaces:
ISuspendable
public class ThreadSuspendable extends ThreadLocalTransferHelper implements ISuspendable
Suspendable for threads.
-
-
Field Summary
Fields Modifier and Type Field Description protected IFuture<?>
future
The future.protected boolean
resumed
The resumed flag to differentiante from timeout.-
Fields inherited from class jadex.commons.future.ThreadLocalTransferHelper
THREADLOCALS, vals
-
Fields inherited from interface jadex.commons.future.ISuspendable
SUSPENDABLE
-
-
Constructor Summary
Constructors Constructor Description ThreadSuspendable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
getDefaultTimeout()
Get the default timeout.java.lang.Object
getMonitor()
Get the monitor for waiting.void
resume(Future<?> future)
Resume the execution of the suspendable.void
suspend(Future<?> future, long timeout, boolean realtime)
Suspend the execution of the suspendable.-
Methods inherited from class jadex.commons.future.ThreadLocalTransferHelper
addThreadLocal, afterSwitch, beforeSwitch, removeThreadLocal, restoreValues, saveValues
-
-
-
-
Field Detail
-
future
protected IFuture<?> future
The future.
-
resumed
protected boolean resumed
The resumed flag to differentiante from timeout.
-
-
Method Detail
-
suspend
public void suspend(Future<?> future, long timeout, boolean realtime)
Suspend the execution of the suspendable.- Specified by:
suspend
in interfaceISuspendable
- Parameters:
timeout
- The timeout.realtime
- Flag if timeout is realtime (in contrast to simulation time).future
- The future to wait for.
-
resume
public void resume(Future<?> future)
Resume the execution of the suspendable.- Specified by:
resume
in interfaceISuspendable
- Parameters:
future
- The future that issues the resume.
-
getMonitor
public java.lang.Object getMonitor()
Get the monitor for waiting.- Specified by:
getMonitor
in interfaceISuspendable
- Returns:
- The monitor.
-
getDefaultTimeout
protected long getDefaultTimeout()
Get the default timeout.- Returns:
- The default timeout (-1 for none).
-
-