Package jadex.future
Class ThreadSuspendable
java.lang.Object
jadex.future.ThreadLocalTransferHelper
jadex.future.ThreadSuspendable
- All Implemented Interfaces:
ISuspendable
Suspendable for threads.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IFuture
<?> The future.protected ReentrantLock
Use reentrant lock/condition instead of synchronized/wait/notify to avoid pinning when using virtual threads.protected boolean
The resumed flag to differentiate from timeout.protected Condition
Threads waiting due to thread suspendable.Fields inherited from class jadex.future.ThreadLocalTransferHelper
THREADLOCALS, vals
Fields inherited from interface jadex.future.ISuspendable
SUSPENDABLE
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class jadex.future.ThreadLocalTransferHelper
addThreadLocal, afterSwitch, beforeSwitch, removeThreadLocal, restoreValues, saveValues
-
Field Details
-
WAITING_THREADS
Threads waiting due to thread suspendable. -
future
The future. -
resumed
protected boolean resumedThe resumed flag to differentiate from timeout. -
lock
Use reentrant lock/condition instead of synchronized/wait/notify to avoid pinning when using virtual threads. -
wait
-
-
Constructor Details
-
ThreadSuspendable
public ThreadSuspendable()
-
-
Method Details
-
suspend
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
Resume the execution of the suspendable.- Specified by:
resume
in interfaceISuspendable
- Parameters:
future
- The future that issues the resume.
-
getLock
Return the lock for internal synchronization.- Specified by:
getLock
in interfaceISuspendable
-
getFuture
Get the future if currently suspended, null otherwise.- Specified by:
getFuture
in interfaceISuspendable
-
getDefaultTimeout
protected long getDefaultTimeout()Get the default timeout.- Returns:
- The default timeout (-1 for none).
-