Skip to main content

InnerSink

Type Alias InnerSink 

Source
type InnerSink = SinkBlocker<SometimesUnboundedSink<(AnyChanCell, Option<QueuedCellPaddingInfo>), ChannelSender>, BooleanPolicy>;
Expand description

Inner type used to implement a CircuitCellSender.

When circ-padding feature is enabled, this is a multi-level wrapper around a ChanSender:

  • On the outermost layer, there is a SinkBlocker that we use to make this sink behave as if it were full when our circuit padding code tells us to block outbound traffic.
  • Then there is a SometimesUnboundedSink that we use to queue control messages when the target ChanSender is full, or when we traffic is blocked.
  • Finally, there is the ChannelSender itself.

NOTE: We once had a second SinkBlocker to keep messages from the SometimesUnboundedSink from reaching the ChanSender when we were blocked on padding. We no longer use this SinkBlocker, since we decided in our padding design that non-data messages would never wait for a padding-based block. We can reinstate it if we change our mind.

TODO: Ideally, this type would participate in the memory quota system.

TODO: At some point in the future, we might want to add an additional bounded futures::sink::Buffer to queue cells before they are put onto the channel, or to queue data from loud streams.

Aliased Type§

struct InnerSink {
    inner: SometimesUnboundedSink<(ChanCell<AnyChanMsg>, Option<QueuedCellPaddingInfo>), ChannelSender>,
    policy: BooleanPolicy,
    waker: Option<Waker>,
}

Fields§

§inner: SometimesUnboundedSink<(ChanCell<AnyChanMsg>, Option<QueuedCellPaddingInfo>), ChannelSender>

The inner sink.

§policy: BooleanPolicy

A policy state object, deciding whether we are blocking or not.

Invariant: Whenever we try to send with a blocking Policy, we store the context’s waker in self.waker. If later the policy becomes non-blocking, we alert the Waker.

§waker: Option<Waker>

A waker that we should alert when policy transitions from a blocking to a non-blocking state.