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 ReentrantLockUse reentrant lock/condition instead of synchronized/wait/notify to avoid pinning when using virtual threads.protected booleanThe resumed flag to differentiate from timeout.protected ConditionThreads waiting due to thread suspendable.Fields inherited from class jadex.future.ThreadLocalTransferHelper
THREADLOCALS, valsFields 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:
suspendin interfaceISuspendable- Parameters:
timeout- The timeout.realtime- Flag if timeout is realtime (in contrast to simulation time).future- The future to wait for.
-
resume
Resume the execution of the suspendable.- Specified by:
resumein interfaceISuspendable- Parameters:
future- The future that issues the resume.
-
getLock
Return the lock for internal synchronization.- Specified by:
getLockin interfaceISuspendable
-
getFuture
Get the future if currently suspended, null otherwise.- Specified by:
getFuturein interfaceISuspendable
-
getDefaultTimeout
protected long getDefaultTimeout()Get the default timeout.- Returns:
- The default timeout (-1 for none).
-