Class SingleConcurrentExecutionStatus
- java.lang.Object
-
- org.eclipse.epsilon.common.concurrent.ConcurrentExecutionStatus
-
- org.eclipse.epsilon.common.concurrent.SingleConcurrentExecutionStatus
-
public class SingleConcurrentExecutionStatus extends ConcurrentExecutionStatus
Utility class which allows for co-ordinating concurrent execution with waiting semantics for successful and exceptional completion. This class is only suitable for single-condition locking, where there is only one success condition registered at any given time. Multiple conditions can be supported using serial thread confinement orMultiConcurrentExecutionStatus
.- Since:
- 1.6
- Author:
- Sina Madani
-
-
Field Summary
Fields Modifier and Type Field Description protected long
waitTimeout
-
Fields inherited from class org.eclipse.epsilon.common.concurrent.ConcurrentExecutionStatus
exception
-
-
Constructor Summary
Constructors Constructor Description SingleConcurrentExecutionStatus()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
completeExceptionally(Throwable exception)
protected void
completeSuccessfully(Object lockObj)
protected void
completeWithResult(Object lockObj, Object result)
protected Object
getResult(Object lockObj)
protected boolean
isInProgress(Object lockObj)
protected boolean
register(Object lockObj)
protected boolean
waitForCompletion(Object lockObj, Supplier<Boolean> targetState)
Waits until either exceptional or successful completion conditions are signalled.Throwable
waitForExceptionalCompletion()
-
Methods inherited from class org.eclipse.epsilon.common.concurrent.ConcurrentExecutionStatus
completeExceptionallyBase, completeSuccessfully, completeWithResult, getException, getResult, isInProgress, register, waitForCompletion, waitForCompletion, waitForCompletion
-
-
-
-
Method Detail
-
getResult
protected final Object getResult(Object lockObj)
- Specified by:
getResult
in classConcurrentExecutionStatus
-
register
protected final boolean register(Object lockObj)
- Specified by:
register
in classConcurrentExecutionStatus
- Returns:
true
if registration was successful.
-
isInProgress
protected final boolean isInProgress(Object lockObj)
- Specified by:
isInProgress
in classConcurrentExecutionStatus
-
completeSuccessfully
protected final void completeSuccessfully(Object lockObj)
- Specified by:
completeSuccessfully
in classConcurrentExecutionStatus
-
completeWithResult
protected final void completeWithResult(Object lockObj, Object result)
- Specified by:
completeWithResult
in classConcurrentExecutionStatus
-
completeExceptionally
public final void completeExceptionally(Throwable exception)
- Specified by:
completeExceptionally
in classConcurrentExecutionStatus
-
waitForCompletion
protected final boolean waitForCompletion(Object lockObj, Supplier<Boolean> targetState)
Waits until either exceptional or successful completion conditions are signalled.- Specified by:
waitForCompletion
in classConcurrentExecutionStatus
- Returns:
- Whether the completion was successful (
true
) or exceptional (false
).
-
waitForExceptionalCompletion
public Throwable waitForExceptionalCompletion()
- Overrides:
waitForExceptionalCompletion
in classConcurrentExecutionStatus
-
-