Package one.tranic.t.base.task
Class Actions<T>
java.lang.Object
one.tranic.t.base.task.Actions<T>
- Type Parameters:
T- the type of the result produced by the encapsulated task
Represents a wrapper for executing tasks either synchronously or asynchronously.
This class encapsulates a task defined by a Supplier, offering methods
for immediate execution or deferred execution using a shared executor.
-
Constructor Details
-
Actions
Constructs a newActionsinstance with the specified task.- Parameters:
task- theSupplierrepresenting the task to be executed
-
-
Method Details
-
sync
Executes the encapsulated task synchronously and returns its result.- Returns:
- the result produced by the encapsulated task
-
async
Executes the encapsulated task asynchronously using a shared executor.- Returns:
- a
CompletableFuture<T>that completes with the result of the asynchronous task execution
-