MuxStream
Individual stream within a Mux.
Encapsulates the state machine for a single stream (IDLE, OPEN, HALF_CLOSED_LOCAL, HALF_CLOSED_REMOTE, CLOSED). Provides send/receive operations and state queries.
This stream has two separate message queues:
- '''Outbound queue''': messages sent by user code via
send(), drained by the mux/protocol viatakeOutbound() - '''Inbound queue''': messages delivered by the mux/protocol via
offerInbound(), read by user code viareceive()
Type parameters
- Id
-
Stream identifier type
- In
-
Message type sent on this stream
- Out
-
Message type received on this stream
Attributes
- Source
- Mux.scala
- Graph
-
- Supertypes
Members list
Value members
Abstract methods
Fully close this stream immediately.
Fully close this stream immediately.
Transitions the stream to CLOSED state and enqueues a terminal error. After this call:
send()fails with MuxError.StreamClosed.receive()drains any already-buffered inbound messages, then returns the terminal error once the buffer is empty.offerInbound()fails with MuxError.StreamClosed.
Attributes
- Source
- Mux.scala
Signal that this side is done sending (END_STREAM equivalent).
Signal that this side is done sending (END_STREAM equivalent).
Transitions: OPEN -> HALF_CLOSED_LOCAL or HALF_CLOSED_REMOTE -> CLOSED
After this, send() will fail. receive() still works.
Attributes
- Source
- Mux.scala
Check if stream is fully closed.
Check if stream is half-closed (one side done).
Check if stream is half-closed (one side done).
Attributes
- Returns
-
true if state is HALF_CLOSED_LOCAL or HALF_CLOSED_REMOTE
- Source
- Mux.scala
Deliver a message to this stream's inbound queue.
Deliver a message to this stream's inbound queue.
Called by the mux/protocol layer to deliver messages TO this stream.
Value parameters
- msg
-
Message to deliver
Attributes
- Returns
-
Success or an error if the stream is closed
- Source
- Mux.scala
Receive a message from the inbound queue.
Receive a message from the inbound queue.
Returns the next available inbound message, or None if no message is available yet. Returns an error if the stream is closed.
Attributes
- Returns
-
Some(msg) if a message is available, None if no message yet, or an error if closed
- Source
- Mux.scala
Send a message on this stream.
Send a message on this stream.
Places the message into the outbound queue for the mux/protocol to drain. Fails if stream is closed or in HALF_CLOSED_LOCAL state.
Value parameters
- msg
-
Message to send
Attributes
- Returns
-
Success or an error
- Source
- Mux.scala
Signal that the remote side is done sending.
Signal that the remote side is done sending.
Transitions: OPEN -> HALF_CLOSED_REMOTE or HALF_CLOSED_LOCAL -> CLOSED
Called by the mux/protocol layer when the peer signals END_STREAM.
Attributes
- Source
- Mux.scala
Take the next message from the outbound queue.
Take the next message from the outbound queue.
Called by the mux/protocol layer to drain messages FROM this stream. Returns None if no outbound message is available.
Attributes
- Returns
-
Some(msg) if a message is available, None if empty, or an error if closed
- Source
- Mux.scala