Package dev.relism.flash.http2.frame
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 timeHttp2FrameWriter.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 TypeMethodDescriptionbyte[]buffer()The buffer holding this intent's already-serialized bytes.default voidCalled exactly once after this intent leaves the writer, whether the socket write succeeded or failed.intlength()Number of bytes to write, starting atoffset().mpscNext()Intrusive MPSC queue linkage — seeIntrusiveMpscQueue.intoffset()Offset of the first byte to write, withinbuffer().voidsetMpscNext(WriteIntent next) Intrusive MPSC queue linkage — seeIntrusiveMpscQueue.
-
Method Details
-
buffer
byte[] buffer()The buffer holding this intent's already-serialized bytes. -
offset
int offset()Offset of the first byte to write, withinbuffer(). -
length
int length()Number of bytes to write, starting atoffset(). -
mpscNext
WriteIntent mpscNext()Intrusive MPSC queue linkage — seeIntrusiveMpscQueue. Not for external use. -
setMpscNext
Intrusive MPSC queue linkage — seeIntrusiveMpscQueue. 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.
-