Interface ExecutionContext

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
CPUExecutionContext, CUDAExecutionContext, DistributedExecutionContext, OpenCLExecutionContext

public interface ExecutionContext extends AutoCloseable
Execution context for running operations on a backend.

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Releases resources associated with this context.
    <T> T
    execute(Operation<T> operation)
    Executes an operation synchronously and returns the result.
    default <T> CompletableFuture<T>
    executeAsync(Operation<T> operation)
    Executes an operation asynchronously.
  • Method Details

    • execute

      <T> T execute(Operation<T> operation)
      Executes an operation synchronously and returns the result.
      Type Parameters:
      T - the result type
      Parameters:
      operation - the operation to execute
      Returns:
      the operation result
      Throws:
      RuntimeException - if execution fails
    • executeAsync

      default <T> CompletableFuture<T> executeAsync(Operation<T> operation)
      Executes an operation asynchronously.
      Type Parameters:
      T - the result type
      Parameters:
      operation - the operation to execute
      Returns:
      a future representing the pending result
    • close

      void close()
      Releases resources associated with this context.

      This method is called automatically when used in try-with-resources.

      Specified by:
      close in interface AutoCloseable