Documentation

Std.Http.Transport.Outbox

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.

  • queued : List (Array ByteArray)

    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 queued in 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.

  • 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.

    Instances For
      def Std.Http.Internal.Outbox.new {α : Type} (socket : α) (writeTimeout : Nat) :

      Creates an outbox that writes to socket, failing a wait for its writes once none has completed for writeTimeout milliseconds.

      Equations
      Instances For
        def Std.Http.Internal.Outbox.send {α : Type} [Transport α] (outbox : Outbox α) (buffer : ChunkedBuffer) :

        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
          Instances For

            A task that finishes once no write is in flight, or none if none is or the outbox failed.

            Equations
            • One or more equations did not get rendered due to their size.
            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.

              How many milliseconds ago the last write completed, or none while a write is in flight.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Returns true once a write failed.

                Equations
                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

                    Takes the error of the failed write, so that only the first caller gets it.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Std.Http.Internal.Outbox.push {α : Type} [Transport α] (outbox : Outbox α) (buffer : ChunkedBuffer) (limit : Nat := 65536) :

                      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.
                      Instances For