Package it.unipd.dei.eis.presentation
Class AsyncExecutor
- java.lang.Object
-
- it.unipd.dei.eis.presentation.AsyncExecutor
-
public class AsyncExecutor extends Object
The AsyncExecutor class is the singleton class that executes the controllers. It contains the execute method.
-
-
Field Summary
Fields Modifier and Type Field Description private static String[]ANIMATIONThe ANIMATION field is the animation of the loading thread.private static intANIMATION_INTERVALThe ANIMATION_INTERVAL field is the interval between two frames of the animation.private static StringANSI_GREENThe ANSI_GREEN field is the ANSI code for green.private static StringANSI_RESETThe ANSI_RESET field is the ANSI code for reset.private static AsyncExecutorinstanceThe instance field is the instance of the AsyncExecutor class.private ThreadloadingThreadThe loadingThread field is the thread that prints the animation of the loading.private longstartTimeThe startTime field is the start time of the loading thread.
-
Constructor Summary
Constructors Modifier Constructor Description privateAsyncExecutor()The AsyncExecutor constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidabort(Exception e)The abort method aborts the loading thread.voidexecute(Supplier<Either<Failure,Success>> supplier, String name)The execute method executes a function.static AsyncExecutorgetInstance()The getInstance method returns the instance of the AsyncExecutor class.private ThreadgetLoadingThread()The getLoadingThread method returns the loading thread.private StringgetLoadingTime()The getLoadingTime method returns the loading time as string.
-
-
-
Field Detail
-
ANIMATION
private static final String[] ANIMATION
The ANIMATION field is the animation of the loading thread.
-
ANIMATION_INTERVAL
private static final int ANIMATION_INTERVAL
The ANIMATION_INTERVAL field is the interval between two frames of the animation.- See Also:
- Constant Field Values
-
ANSI_GREEN
private static final String ANSI_GREEN
The ANSI_GREEN field is the ANSI code for green.- See Also:
- Constant Field Values
-
ANSI_RESET
private static final String ANSI_RESET
The ANSI_RESET field is the ANSI code for reset.- See Also:
- Constant Field Values
-
instance
private static AsyncExecutor instance
The instance field is the instance of the AsyncExecutor class.
-
loadingThread
private Thread loadingThread
The loadingThread field is the thread that prints the animation of the loading.
-
startTime
private long startTime
The startTime field is the start time of the loading thread.
-
-
Method Detail
-
getInstance
public static AsyncExecutor getInstance()
The getInstance method returns the instance of the AsyncExecutor class.- Returns:
- the instance of the AsyncExecutor class
-
abort
private void abort(Exception e)
The abort method aborts the loading thread. Find the cause of the exception and throw a RuntimeException.- Parameters:
e- the exception
-
execute
public void execute(Supplier<Either<Failure,Success>> supplier, String name)
The execute method executes a function.- Parameters:
supplier- the function to be executedname- the name of the function
-
getLoadingThread
private Thread getLoadingThread()
The getLoadingThread method returns the loading thread.- Returns:
- the loading thread
-
getLoadingTime
private String getLoadingTime()
The getLoadingTime method returns the loading time as string.- Returns:
- the loading time
-
-