Outbox #
An Outbox writes a connection's output to its transport in order, without the connection waiting
for each write.
The state of an Outbox.
Output handed over while a write was in flight, newest first, written together once it completes. A list, because the state is shared with the thread that completes the write, so an array here would be copied on every append.
- queuedBytes : Nat
The size of
queuedin bytes. - writing : Bool
A write is in flight.
- failed : Bool
A write failed, so later output is dropped.
The error of the failed write, until it is taken.
- idle : Option (IO.Promise Unit)
Resolved once no write is in flight.
- idleSince : Nat
When the last write completed, by
IO.monoMsNow. - progressAt : Nat
When a write last started with none in flight or completed, by
IO.monoMsNow.
Instances For
Writes a connection's output to socket in order without the connection waiting for it. At most
one write is in flight. Output handed over meanwhile goes out in a single write once that write
completes, started by the thread that completed it.
- socket : α
The transport the output is written to.
- writeTimeout : Nat
How long, in milliseconds, a wait for output to be written lasts without any write completing before the outbox fails.
- state : IO.Ref Std.Http.Internal.Outbox.State
Instances For
Creates an outbox that writes to socket, failing a wait for its writes once none has completed for
writeTimeout milliseconds.
Equations
Instances For
Hands buffer to the outbox, which writes it after everything handed over before. Returns how many
bytes now wait behind the write in flight, or none if a write failed and buffer was dropped.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true while a write is in flight.
Equations
- outbox.writing = do let __do_lift ← ST.Ref.get (Std.Http.Internal.Outbox.state✝ outbox) pure __do_lift.writing
Instances For
Waits until no write is in flight. If no write completes for writeTimeout milliseconds meanwhile,
the outbox fails instead, so a peer that stops reading cannot hold the connection.
Returns true once a write failed.
Equations
- outbox.failed = do let __do_lift ← ST.Ref.get (Std.Http.Internal.Outbox.state✝ outbox) pure __do_lift.failed
Instances For
Waits until every write handed over so far completed. Returns false if a write failed or none
completed within writeTimeout.
Equations
Instances For
Hands buffer to the outbox, then waits for its writes if more than limit bytes are queued, so a
peer that does not read holds up the caller instead of growing its memory. Returns false if a
write failed or none completed within writeTimeout.
Equations
- One or more equations did not get rendered due to their size.