|
| 1 | +use crate::Reason; |
| 2 | + |
1 | 3 | use super::*;
|
2 | 4 |
|
3 | 5 | use std::task::{Context, Waker};
|
@@ -104,6 +106,9 @@ pub(super) struct Stream {
|
104 | 106 | /// Task tracking receiving frames
|
105 | 107 | pub recv_task: Option<Waker>,
|
106 | 108 |
|
| 109 | + /// Task tracking pushed promises. |
| 110 | + pub push_task: Option<Waker>, |
| 111 | + |
107 | 112 | /// The stream's pending push promises
|
108 | 113 | pub pending_push_promises: store::Queue<NextAccept>,
|
109 | 114 |
|
@@ -186,6 +191,7 @@ impl Stream {
|
186 | 191 | pending_recv: buffer::Deque::new(),
|
187 | 192 | is_recv: true,
|
188 | 193 | recv_task: None,
|
| 194 | + push_task: None, |
189 | 195 | pending_push_promises: store::Queue::new(),
|
190 | 196 | content_length: ContentLength::Omitted,
|
191 | 197 | }
|
@@ -369,6 +375,20 @@ impl Stream {
|
369 | 375 | task.wake();
|
370 | 376 | }
|
371 | 377 | }
|
| 378 | + |
| 379 | + pub(super) fn notify_push(&mut self) { |
| 380 | + if let Some(task) = self.push_task.take() { |
| 381 | + task.wake(); |
| 382 | + } |
| 383 | + } |
| 384 | + |
| 385 | + /// Set the stream's state to `Closed` with the given reason and initiator. |
| 386 | + /// Notify the send and receive tasks, if they exist. |
| 387 | + pub(super) fn set_reset(&mut self, reason: Reason, initiator: Initiator) { |
| 388 | + self.state.set_reset(self.id, reason, initiator); |
| 389 | + self.notify_push(); |
| 390 | + self.notify_recv(); |
| 391 | + } |
372 | 392 | }
|
373 | 393 |
|
374 | 394 | impl store::Next for NextAccept {
|
|
0 commit comments