Interface WriteIntent

All Known Implementing Classes:
Http2ResponseWriter

public interface WriteIntent
"Serialize yourself, then hand me the finished bytes." The interface a stream (and, eventually, connection-level singletons — the precompiled SETTINGS ACK, PING ACK, GOAWAY, WINDOW_UPDATE frames) implements to write through Http2FrameWriter.

Layer 1 — serialize outside the lock

By the time Http2FrameWriter.write(dev.relism.flash.http2.frame.WriteIntent) is called, the implementation has already built its complete output (frame header + HPACK block + payload, or whatever the frame needs) into a buffer it owns — a per-stream scratch buffer, reused across writes, never allocated per call. buffer()/offset()/length() just describe where that already-finished output lives. Http2FrameWriter never serializes anything itself; it only ever issues one bulk write(buffer, offset, length) while holding the connection's write lock — see WRITER.md for why that distinction is the entire point of this design (the lock must never be held across serialization work, only across the syscall).

Intrusive queue linkage

mpscNext()/setMpscNext(dev.relism.flash.http2.frame.WriteIntent) are not part of the writer's public contract — they exist so a WriteIntent can double as an IntrusiveMpscQueue node with zero extra allocation when the writer is contended. Implementations provide simple field storage; nothing about the field is meaningful outside IntrusiveMpscQueue.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    The buffer holding this intent's already-serialized bytes.
    default void
    Called exactly once after this intent leaves the writer, whether the socket write succeeded or failed.
    int
    Number of bytes to write, starting at offset().
    Intrusive MPSC queue linkage — see IntrusiveMpscQueue.
    int
    Offset of the first byte to write, within buffer().
    void
    Intrusive MPSC queue linkage — see IntrusiveMpscQueue.
  • Method Details

    • buffer

      byte[] buffer()
      The buffer holding this intent's already-serialized bytes.
    • offset

      int offset()
      Offset of the first byte to write, within buffer().
    • length

      int length()
      Number of bytes to write, starting at offset().
    • mpscNext

      WriteIntent mpscNext()
      Intrusive MPSC queue linkage — see IntrusiveMpscQueue. Not for external use.
    • setMpscNext

      void setMpscNext(WriteIntent next)
      Intrusive MPSC queue linkage — see IntrusiveMpscQueue. Not for external use.
    • completed

      default void completed()
      Called exactly once after this intent leaves the writer, whether the socket write succeeded or failed. Pooled control-frame intents use this hook to return their slot to the owning connection without allocating a completion object.