Enum Class ConnectionState

java.lang.Object
java.lang.Enum<ConnectionState>
express.mvp.myra.transport.iouring.ConnectionState
All Implemented Interfaces:
Serializable, Comparable<ConnectionState>, Constable

public enum ConnectionState extends Enum<ConnectionState>
Represents the lifecycle state of a transport connection.

This enum tracks the connection state machine for both client and server sockets in the io_uring transport backend. State transitions are thread-safe via volatile field access in the backend.

State Machine

                   ┌──────────────┐
                   │ DISCONNECTED │ (Initial state)
                   └──────┬───────┘
                          │ connect() called
                          ▼
                   ┌──────────────┐
                   │  CONNECTING  │ (Async connect in progress)
                   └──────┬───────┘
          ┌───────────────┴───────────────┐
          │ success                       │ failure
          ▼                               ▼
   ┌──────────────┐                ┌──────────────┐
   │  CONNECTED   │                │ DISCONNECTED │
   └──────┬───────┘                └──────────────┘
          │ close() called or error
          ▼
   ┌──────────────┐
   │   CLOSING    │ (Graceful shutdown)
   └──────┬───────┘
          │ cleanup complete
          ▼
   ┌──────────────┐
   │    CLOSED    │ (Terminal state)
   └──────────────┘

Thread Safety

State transitions should be performed under synchronization in the backend. State checks (canConnect, canDoIO, canClose) can be performed without synchronization for fast-path decisions.

See Also:
  • IoUringBackend.connectionState
  • Enum Constant Details

    • DISCONNECTED

      public static final ConnectionState DISCONNECTED
      Initial state - no connection established. Valid operations: connect(), bind()
    • CONNECTING

      public static final ConnectionState CONNECTING
      Asynchronous connection attempt in progress. The io_uring connect operation has been submitted but not yet completed. No I/O operations are allowed in this state.
    • CONNECTED

      public static final ConnectionState CONNECTED
      Connection established and ready for I/O operations. Valid operations: send(), receive(), close()
    • CLOSING

      public static final ConnectionState CLOSING
      Graceful shutdown in progress. Outstanding I/O operations are being drained before final close. No new I/O operations are allowed.
    • CLOSED

      public static final ConnectionState CLOSED
      Connection closed - terminal state. No operations are allowed. Backend resources have been released.
  • Method Details

    • values

      public static ConnectionState[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ConnectionState valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • canConnect

      public boolean canConnect()
      Checks if the connect operation can be initiated in this state.
      Returns:
      true if state is DISCONNECTED (ready for new connection)
    • canDoIO

      public boolean canDoIO()
      Checks if I/O operations (send/receive) can be performed in this state.
      Returns:
      true if state is CONNECTED (ready for I/O)
    • canClose

      public boolean canClose()
      Checks if the close operation can be initiated in this state.
      Returns:
      true if state is CONNECTED or CONNECTING (active connection to close)