Package javascalautils.concurrent
Interface Executable<T>
-
- Type Parameters:
T
- The type this executable is expected to work on
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Executable<T>
A task that returns either a successful or failed result.
Implementors define a single method with calledexecute
.
TheExecutable
interface is similar toRunnable
andCallable
, in that both are designed for classes whose instances are potentially executed by another thread.
However this class allows the user to respond with eithersuccess
orfailure
.- Since:
- 1.2
- See Also:
Executor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
execute(Promise<T> promise)
Execute the job.
-
-
-
Method Detail
-
execute
void execute(Promise<T> promise)
Execute the job.
Any response needs to be reported via eitherPromise,success(T)
orPromise.failure(Throwable)
.
When this method has finished it is imperative that the implementation has reported either failure/success. If not the framework will automatically report the execution as a failure due to a missing response.- Parameters:
promise
- The promise to report the response to- Since:
- 1.2
-
-