Package jadex.bridge.service.component
Class ComponentSuspendable
- java.lang.Object
-
- jadex.commons.future.ThreadLocalTransferHelper
-
- jadex.bridge.service.component.ComponentSuspendable
-
- All Implemented Interfaces:
ISuspendable
public class ComponentSuspendable extends ThreadLocalTransferHelper implements ISuspendable
Allow waiting for futures by blocking a component.
-
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
agent
The component adapter.static java.lang.ThreadLocal<ComponentSuspendable>
COMSUPS
The component suspendables.protected Future<?>
future
The current future.protected java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object>
vals
The thread locals.-
Fields inherited from class jadex.commons.future.ThreadLocalTransferHelper
THREADLOCALS
-
Fields inherited from interface jadex.commons.future.ISuspendable
SUSPENDABLE
-
-
Constructor Summary
Constructors Constructor Description ComponentSuspendable(IInternalAccess agent)
Create a component suspendable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getDefaultTimeout()
Get the default timeout.Future<?>
getFuture()
Get the future.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.java.lang.String
toString()
Get the string representation.-
Methods inherited from class jadex.commons.future.ThreadLocalTransferHelper
addThreadLocal, afterSwitch, beforeSwitch, removeThreadLocal, restoreValues, saveValues
-
-
-
-
Field Detail
-
COMSUPS
public static final java.lang.ThreadLocal<ComponentSuspendable> COMSUPS
The component suspendables.
-
agent
protected IInternalAccess agent
The component adapter.
-
future
protected Future<?> future
The current future.
-
vals
protected java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> vals
The thread locals.
-
-
Constructor Detail
-
ComponentSuspendable
public ComponentSuspendable(IInternalAccess agent)
Create a component suspendable.
-
-
Method Detail
-
suspend
public void suspend(Future<?> future, long timeout, boolean realtime)
Suspend the execution of the suspendable.- Specified by:
suspend
in interfaceISuspendable
- Parameters:
future
- The future to wait for.timeout
- The timeout.realtime
- Flag if timeout is realtime (in contrast to simulation time).
-
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.
-
getFuture
public Future<?> getFuture()
Get the future.- Returns:
- The future.
-
getDefaultTimeout
public long getDefaultTimeout()
Get the default timeout.- Returns:
- The default timeout (-1 for none).
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toString
in classjava.lang.Object
-
-