Skip to content

Future state machine

The Future state machine is a conceptual model used in asynchronous programming, specifically within the Netty framework, to represent the lifecycle of a computation result.^[600-developer-big-data-netty-netty-future.md]

State Diagram

The lifecycle of a Future is defined by its transition from an uncompleted state to one of three possible completed states.^[600-developer-big-data-netty-netty-future.md] This structure is encapsulated in the io.netty.util.concurrent.Future and io.netty.channel.ChannelFuture interfaces.^[600-developer-big-data-netty-netty-future.md]

The machine operates based on the following state transitions^[600-developer-big-data-netty-netty-future.md]:

  1. Uncompleted: The initial state where the computation is pending.

    • isDone() = false
    • isSuccess() = false
    • isCancelled() = false
    • cause() = null
  2. Completed successfully: The computation finished without errors.

    • isDone() = true
    • isSuccess() = true
  3. Completed with failure: The computation terminated with an exception.

    • isDone() = true
    • cause() = non-null
  4. Completed by cancellation: The computation was interrupted before completion.

    • isDone() = true
    • isCancelled() = true
  • Promise
  • [[Asynchronous programming]]

Sources

  • 600-developer-big-data-netty-netty-future.md