More flow control work
This commit is contained in:
		| @@ -14,6 +14,9 @@ pub(super) struct Stream<B> { | ||||
|     /// Task tracking receiving frames | ||||
|     pub recv_task: Option<task::Task>, | ||||
|  | ||||
|     /// Task tracking additional send capacity (i.e. window updates). | ||||
|     pub send_task: Option<task::Task>, | ||||
|  | ||||
|     /// Frames pending for this stream being sent to the socket | ||||
|     pub pending_send: buffer::Deque<B>, | ||||
|  | ||||
| @@ -23,6 +26,13 @@ pub(super) struct Stream<B> { | ||||
|     /// state. | ||||
|     pub next: Option<store::Key>, | ||||
|  | ||||
|     /// Next node in the linked list of streams waiting for additional | ||||
|     /// connection level capacity. | ||||
|     pub next_capacity: Option<store::Key>, | ||||
|  | ||||
|     /// True if the stream is waiting for outbound connection capacity | ||||
|     pub is_pending_send_capacity: bool, | ||||
|  | ||||
|     /// The stream's pending push promises | ||||
|     pub pending_push_promises: store::List<B>, | ||||
|  | ||||
| @@ -35,6 +45,12 @@ pub(super) struct Stream<B> { | ||||
|     pub unadvertised_send_window: WindowSize, | ||||
| } | ||||
|  | ||||
| #[derive(Debug)] | ||||
| pub(super) struct Next; | ||||
|  | ||||
| #[derive(Debug)] | ||||
| pub(super) struct NextCapacity; | ||||
|  | ||||
| impl<B> Stream<B> { | ||||
|     pub fn new(id: StreamId) -> Stream<B> { | ||||
|         Stream { | ||||
| @@ -42,8 +58,11 @@ impl<B> Stream<B> { | ||||
|             state: State::default(), | ||||
|             pending_recv: buffer::Deque::new(), | ||||
|             recv_task: None, | ||||
|             send_task: None, | ||||
|             pending_send: buffer::Deque::new(), | ||||
|             next: None, | ||||
|             next_capacity: None, | ||||
|             is_pending_send_capacity: false, | ||||
|             pending_push_promises: store::List::new(), | ||||
|             is_pending_send: false, | ||||
|             unadvertised_send_window: 0, | ||||
| @@ -60,9 +79,45 @@ impl<B> Stream<B> { | ||||
|         self.state.recv_flow_control() | ||||
|     } | ||||
|  | ||||
|     pub fn notify_send(&mut self) { | ||||
|         if let Some(task) = self.send_task.take() { | ||||
|             task.notify(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub fn notify_recv(&mut self) { | ||||
|         if let Some(ref mut task) = self.recv_task { | ||||
|         if let Some(task) = self.recv_task.take() { | ||||
|             task.notify(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl store::Next for Next { | ||||
|     fn next<B>(stream: &Stream<B>) -> Option<store::Key> { | ||||
|         stream.next | ||||
|     } | ||||
|  | ||||
|     fn set_next<B>(stream: &mut Stream<B>, key: store::Key) { | ||||
|         debug_assert!(stream.next.is_none()); | ||||
|         stream.next = Some(key); | ||||
|     } | ||||
|  | ||||
|     fn take_next<B>(stream: &mut Stream<B>) -> store::Key { | ||||
|         stream.next.take().unwrap() | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl store::Next for NextCapacity { | ||||
|     fn next<B>(stream: &Stream<B>) -> Option<store::Key> { | ||||
|         stream.next_capacity | ||||
|     } | ||||
|  | ||||
|     fn set_next<B>(stream: &mut Stream<B>, key: store::Key) { | ||||
|         debug_assert!(stream.next_capacity.is_none()); | ||||
|         stream.next_capacity = Some(key); | ||||
|     } | ||||
|  | ||||
|     fn take_next<B>(stream: &mut Stream<B>) -> store::Key { | ||||
|         stream.next_capacity.take().unwrap() | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user