Skip to content

Commit

Permalink
split FlowControl into FlowControlRecv and FlowControlSend
Browse files Browse the repository at this point in the history
  • Loading branch information
olix0r committed Jul 24, 2017
1 parent 40b57cb commit 1dbbac2
Show file tree
Hide file tree
Showing 6 changed files with 469 additions and 364 deletions.
21 changes: 18 additions & 3 deletions src/proto/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ use proto::*;

/// Exposes flow control states to "upper" layers of the transport (i.e. above
/// FlowControl).
pub trait ControlFlow {
pub trait ControlFlowSend {
/// Polls for the next window update from the remote.
fn poll_window_update(&mut self) -> Poll<WindowUpdate, ConnectionError>;
}

pub trait ControlFlowRecv {
/// Increases the local receive capacity of a stream.
///
/// This may cause a window update to be sent to the remote.
Expand All @@ -15,16 +17,29 @@ pub trait ControlFlow {
fn expand_window(&mut self, id: StreamId, incr: WindowSize) -> Result<(), ConnectionError>;
}

macro_rules! proxy_control_flow {
macro_rules! proxy_control_flow_send {
($outer:ident) => (
impl<T: ControlFlow> ControlFlow for $outer<T> {
impl<T: ControlFlowSend> ControlFlowSend for $outer<T> {
fn poll_window_update(&mut self) -> Poll<WindowUpdate, ConnectionError> {
self.inner.poll_window_update()
}
}
)
}

macro_rules! proxy_control_flow_recv {
($outer:ident) => (
impl<T: ControlFlowRecv> ControlFlowRecv for $outer<T> {
fn expand_window(&mut self, id: StreamId, incr: WindowSize) -> Result<(), ConnectionError> {
self.inner.expand_window(id, incr)
}
}
)
}

macro_rules! proxy_control_flow {
($outer:ident) => (
proxy_control_flow_recv!($outer);
proxy_control_flow_send!($outer);
)
}
335 changes: 0 additions & 335 deletions src/proto/flow_control.rs

This file was deleted.

Loading

0 comments on commit 1dbbac2

Please sign in to comment.