We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 54fb72c commit 3ee6af2Copy full SHA for 3ee6af2
tokio/tests/io_copy_bidirectional.rs
@@ -138,3 +138,28 @@ async fn immediate_exit_on_read_error() {
138
139
assert!(copy_bidirectional(&mut a, &mut b).await.is_err());
140
}
141
+
142
+#[tokio::test]
143
+async fn copy_bidirectional_is_cooperative() {
144
+ tokio::select! {
145
+ biased;
146
+ _ = async {
147
+ loop {
148
+ let payload = b"here, take this";
149
150
+ let mut a = tokio_test::io::Builder::new()
151
+ .read(payload)
152
+ .write(payload)
153
+ .build();
154
155
+ let mut b = tokio_test::io::Builder::new()
156
157
158
159
160
+ let _ = copy_bidirectional(&mut a, &mut b).await;
161
+ }
162
+ } => {},
163
+ _ = tokio::task::yield_now() => {}
164
165
+}
0 commit comments