id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2
.await .unwrap(); let (server, _) = listener.accept().await.unwrap(); let mut written = DATA.to_vec(); // Track the server receiving data let mut readable = task::spawn(server.readable()); assert_pending!(readable.poll()); // Write data. client.writable().await.unwrap(); assert...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
41
100
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3
let mut i = 0; while i < read.len() { server.readable().await.unwrap(); match server.try_read(&mut read[i..]) { Ok(n) => i += n, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("error = {e:?}"), ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
81
140
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4
let mut read = vec![0; written.len()]; let mut i = 0; while i < read.len() { server.readable().await.unwrap(); let mut bufs: Vec<_> = read[i..] .chunks_mut(0x10000) .map(io::IoSliceMut::new) .collect(); match server.tr...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
121
180
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5
let fut = async { let stream = TcpStream::connect("127.0.0.1:8080").await.unwrap(); loop { stream.readable().await.unwrap(); let mut buf = [0; N]; let n = stream.try_read(&mut buf[..]).unwrap(); if n == 0 { break; } }...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
161
220
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6
macro_rules! assert_not_writable_by_polling { ($stream:expr) => { poll_fn(|cx| { assert_pending!($stream.poll_write_ready(cx)); Poll::Ready(()) }) .await; }; } #[tokio::test] #[cfg_attr(miri, ignore)] // No `socket` on miri. async fn poll_read_ready() { let (...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
201
260
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7
// Initial state - writable. assert_writable_by_polling!(client); // No space to write - not writable. write_until_pending(&mut client); assert_not_writable_by_polling!(client); // Detect the server disconnect. drop(server); assert_writable_by_polling!(client); } async fn create_pair() ->...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
241
300
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8
Err(err) => { assert_eq!(err.kind(), io::ErrorKind::WouldBlock); break; } } } total } #[tokio::test] #[cfg_attr(miri, ignore)] // No `socket` on miri. async fn try_read_buf() { const DATA: &[u8] = b"this is some data to write to the socket"; // Creat...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
281
340
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9
let mut writable = task::spawn(client.writable()); assert_ready_ok!(writable.poll()); match client.try_write(DATA) { Ok(n) => written.extend(&DATA[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { break; } Err(e) => panic!("e...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_stream.rs
321
380
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_read...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2
let (server, _) = listener.accept().await.unwrap(); let mut written = DATA.to_vec(); // Track the server receiving data let mut readable = task::spawn(server.readable()); assert_pending!(readable.poll()); // Write data. client.writable().await.unwrap(); assert_eq!(DATA.len(), client.try_wr...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
41
100
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3
while i < read.len() { server.readable().await.unwrap(); match server.try_read(&mut read[i..]) { Ok(n) => i += n, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("error = {e:?}"), } } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
81
140
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4
while i < read.len() { server.readable().await.unwrap(); let mut bufs: Vec<_> = read[i..] .chunks_mut(0x10000) .map(io::IoSliceMut::new) .collect(); match server.try_read_vectored(&mut bufs) { Ok(n) => i += n, ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
121
180
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5
loop { stream.readable().await.unwrap(); let mut buf = [0; N]; let n = stream.try_read(&mut buf[..]).unwrap(); if n == 0 { break; } } }; let n = mem::size_of_val(&fut); assert!(n < 1000); } macro_rules! assert_readable_b...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
161
220
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6
($stream:expr) => { poll_fn(|cx| { assert_pending!($stream.poll_write_ready(cx)); Poll::Ready(()) }) .await; }; } #[tokio::test] async fn poll_read_ready() { let (mut client, mut server) = create_pair().await; // Initial state - not readable. assert_not_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
201
260
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7
write_until_pending(&mut client); assert_not_writable_by_polling!(client); // Detect the server disconnect. drop(server); assert_writable_by_polling!(client); } async fn create_pair() -> (TcpStream, TcpStream) { let listener = assert_ok!(TcpListener::bind("127.0.0.1:0").await); let addr = asse...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
241
300
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8
} } total } #[tokio::test] async fn try_read_buf() { const DATA: &[u8] = b"this is some data to write to the socket"; // Create listener let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = TcpStream::connect(listener.local_addr().unwrap()) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
281
340
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { break; } Err(e) => panic!("error = {e:?}"), } } { // Write buffer full let mut writable = task::spawn(client.writable()); assert_pending!(writable.poll()); // Drain the sock...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
321
380
tokio-rs/tokio:tokio/tests/tcp_stream.rs:10
} } // read_closed is a best effort event, so test only for no false positives. #[tokio::test] async fn read_closed() { let (client, mut server) = create_pair().await; let mut ready_fut = task::spawn(client.ready(Interest::READABLE)); assert_pending!(ready_fut.poll()); assert_ok!(server.write_all(b"p...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/tcp_stream.rs
361
399
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2
let (server, _) = listener.accept().await.unwrap(); let mut written = DATA.to_vec(); // Track the server receiving data let mut readable = task::spawn(server.readable()); assert_pending!(readable.poll()); // Write data. client.writable().await.unwrap(); assert_eq!(DATA.len(), client.try_wr...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_stream.rs
41
100
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3
while i < read.len() { server.readable().await.unwrap(); match server.try_read(&mut read[i..]) { Ok(n) => i += n, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("error = {:?}", e), } } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_stream.rs
81
140
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4
while i < read.len() { server.readable().await.unwrap(); let mut bufs: Vec<_> = read[i..] .chunks_mut(0x10000) .map(io::IoSliceMut::new) .collect(); match server.try_read_vectored(&mut bufs) { Ok(n) => i += n, ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_stream.rs
121
180
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8
} } total } #[tokio::test] async fn try_read_buf() { const DATA: &[u8] = b"this is some data to write to the socket"; // Create listener let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = TcpStream::connect(listener.local_addr().unwrap()) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_stream.rs
281
340
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { break; } Err(e) => panic!("error = {:?}", e), } } { // Write buffer full let mut writable = task::spawn(client.writable()); assert_pending!(writable.poll()); // Drain the so...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_stream.rs
321
380
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2
.unwrap(); let (server, _) = listener.accept().await.unwrap(); let mut written = DATA.to_vec(); // Track the server receiving data let mut readable = task::spawn(server.readable()); assert_pending!(readable.poll()); // Write data. client.writable().await.unwrap(); assert_eq!(DATA.len()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
41
100
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3
while i < read.len() { server.readable().await.unwrap(); match server.try_read(&mut read[i..]) { Ok(n) => i += n, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("error = {:?}", e), } } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
81
140
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4
let mut i = 0; while i < read.len() { server.readable().await.unwrap(); let mut bufs: Vec<_> = read[i..] .chunks_mut(0x10000) .map(io::IoSliceMut::new) .collect(); match server.try_read_vectored(&mut bufs) { Ok...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
121
180
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5
let stream = TcpStream::connect("127.0.0.1:8080").await.unwrap(); loop { stream.readable().await.unwrap(); let mut buf = [0; N]; let n = stream.try_read(&mut buf[..]).unwrap(); if n == 0 { break; } } }; let n = mem::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
161
220
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6
macro_rules! assert_not_writable_by_polling { ($stream:expr) => { poll_fn(|cx| { assert_pending!($stream.poll_write_ready(cx)); Poll::Ready(()) }) .await; }; } #[tokio::test] async fn poll_read_ready() { let (mut client, mut server) = create_pair().await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
201
260
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7
// No space to write - not writable. write_until_pending(&mut client); assert_not_writable_by_polling!(client); // Detect the server disconnect. drop(server); assert_writable_by_polling!(client); } async fn create_pair() -> (TcpStream, TcpStream) { let listener = assert_ok!(TcpListener::bind("...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
241
300
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8
} } } total } #[tokio::test] async fn try_read_buf() { const DATA: &[u8] = b"this is some data to write to the socket"; // Create listener let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = TcpStream::connect(listener.local_addr().un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
281
340
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9
Ok(n) => written.extend(&DATA[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { break; } Err(e) => panic!("error = {:?}", e), } } { // Write buffer full let mut writable = task::spawn(client.writable()); assert_pe...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
321
380
tokio-rs/tokio:tokio/tests/tcp_stream.rs:10
} } } // read_closed is a best effort event, so test only for no false positives. #[tokio::test] async fn read_closed() { let (client, mut server) = create_pair().await; let mut ready_fut = task::spawn(client.ready(Interest::READABLE)); assert_pending!(ready_fut.poll()); assert_ok!(server.write_a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_stream.rs
361
400
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use std::io...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
644cb8207df09c19543cf9b096a43a66f8df9a0f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6
macro_rules! assert_not_writable_by_polling { ($stream:expr) => { poll_fn(|cx| { assert_pending!($stream.poll_write_ready(cx)); Poll::Ready(()) }) .await; }; } #[tokio::test] async fn poll_read_ready() { let (mut client, mut server) = create_pair().await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_stream.rs
201
260
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7
// No space to write - not writable. write_until_pending(&mut client); assert_not_writable_by_polling!(client); // Detect the server disconnect. drop(server); assert_writable_by_polling!(client); } async fn create_pair() -> (TcpStream, TcpStream) { let listener = assert_ok!(TcpListener::bind("...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_stream.rs
241
300
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8
} #[tokio::test] async fn try_read_buf() { const DATA: &[u8] = b"this is some data to write to the socket"; // Create listener let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = TcpStream::connect(listener.local_addr().unwrap()) .await ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_stream.rs
281
340
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9
Err(e) => panic!("error = {:?}", e), } } { // Write buffer full let mut writable = task::spawn(client.writable()); assert_pending!(writable.poll()); // Drain the socket from the server end let mut read = Vec::with_capacity(written.len()); let mut i = 0; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_stream.rs
321
359
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use std::io; use std::task::Poll; use std::time::Duration; us...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
0b93bd511da6e96eaa9237760dc9683710ebdabc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b93bd511da6e96eaa9237760dc9683710ebdabc/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use std::io; use std::task::Poll; use std::time::Duration; us...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2
.unwrap(); let (server, _) = listener.accept().await.unwrap(); let mut written = DATA.to_vec(); // Track the server receiving data let mut readable = task::spawn(server.readable()); assert_pending!(readable.poll()); // Write data. client.writable().await.unwrap(); assert_eq!(DATA.len()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
41
100
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3
while i < read.len() { server.readable().await.unwrap(); match server.try_read(&mut read[i..]) { Ok(n) => i += n, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("error = {:?}", e), } } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
81
140
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4
let mut buf = [0; N]; let n = stream.try_read(&mut buf[..]).unwrap(); if n == 0 { break; } } }; let n = mem::size_of_val(&fut); assert!(n < 1000); } macro_rules! assert_readable_by_polling { ($stream:expr) => { assert_ok!(poll_fn(|cx...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
121
180
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5
}) .await; }; } #[tokio::test] async fn poll_read_ready() { let (mut client, mut server) = create_pair().await; // Initial state - not readable. assert_not_readable_by_polling!(server); // There is data in the buffer - readable. assert_ok!(client.write_all(b"ping").await); assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
161
220
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6
drop(server); assert_writable_by_polling!(client); } async fn create_pair() -> (TcpStream, TcpStream) { let listener = assert_ok!(TcpListener::bind("127.0.0.1:0").await); let addr = assert_ok!(listener.local_addr()); let (client, (server, _)) = assert_ok!(try_join!(TcpStream::connect(&addr), listener.a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
201
260
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7
// Create listener let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = TcpStream::connect(listener.local_addr().unwrap()) .await .unwrap(); let (server, _) = listener.accept().await.unwrap(); let mut written = DATA.to_vec(); // Tra...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
241
300
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8
// Write buffer full let mut writable = task::spawn(client.writable()); assert_pending!(writable.poll()); // Drain the socket from the server end let mut read = Vec::with_capacity(written.len()); let mut i = 0; while i < read.capacity() { server.readable().a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
3b6bee822dfe70caea7eb22b51fefb28d162f966
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/tcp_stream.rs
281
314
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6
drop(server); assert_writable_by_polling!(client); } async fn create_pair() -> (TcpStream, TcpStream) { let listener = assert_ok!(TcpListener::bind("127.0.0.1:0").await); let addr = assert_ok!(listener.local_addr()); let (client, (server, _)) = assert_ok!(try_join!(TcpStream::connect(&addr), listener.a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
7d11aa866837eea50a6f1e0ef7e24846a653cbf1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7d11aa866837eea50a6f1e0ef7e24846a653cbf1/tokio/tests/tcp_stream.rs
201
236
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; use std::io; use std::task::Poll; use futures::future::poll_f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4e39c9b818eb8af064bb9f45f47e3cfc6593de95
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4e39c9b818eb8af064bb9f45f47e3cfc6593de95/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2
// Fill the write buffer loop { // Still ready let mut writable = task::spawn(client.writable()); assert_ready_ok!(writable.poll()); match client.try_write(DATA) { Ok(n) => written.extend(&DATA[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4e39c9b818eb8af064bb9f45f47e3cfc6593de95
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4e39c9b818eb8af064bb9f45f47e3cfc6593de95/tokio/tests/tcp_stream.rs
41
100
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3
loop { let ready = server.ready(Interest::READABLE).await.unwrap(); if ready.is_read_closed() { return; } else { tokio::task::yield_now().await; } } } #[test] fn buffer_not_included_in_future() { use std::mem; const N: usize = 4096; let fut = a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4e39c9b818eb8af064bb9f45f47e3cfc6593de95
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4e39c9b818eb8af064bb9f45f47e3cfc6593de95/tokio/tests/tcp_stream.rs
81
140
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4
}; } macro_rules! assert_not_readable_by_polling { ($stream:expr) => { poll_fn(|cx| { assert_pending!($stream.poll_read_ready(cx)); Poll::Ready(()) }) .await; }; } macro_rules! assert_writable_by_polling { ($stream:expr) => { assert_ok!(poll_fn(|cx| ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4e39c9b818eb8af064bb9f45f47e3cfc6593de95
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4e39c9b818eb8af064bb9f45f47e3cfc6593de95/tokio/tests/tcp_stream.rs
121
180
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5
// Readable until calls to `poll_read` return `Poll::Pending`. let mut buf = [0u8; 4]; assert_ok!(server.read_exact(&mut buf).await); assert_readable_by_polling!(server); read_until_pending(&mut server); assert_not_readable_by_polling!(server); // Detect the client disconnect. drop(client);...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4e39c9b818eb8af064bb9f45f47e3cfc6593de95
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4e39c9b818eb8af064bb9f45f47e3cfc6593de95/tokio/tests/tcp_stream.rs
161
220
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6
Err(err) => { assert_eq!(err.kind(), io::ErrorKind::WouldBlock); break; } } } } fn write_until_pending(stream: &mut TcpStream) { let buf = vec![0u8; 1024 * 1024]; loop { match stream.try_write(&buf) { Ok(_) => (), Err(err) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
4e39c9b818eb8af064bb9f45f47e3cfc6593de95
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4e39c9b818eb8af064bb9f45f47e3cfc6593de95/tokio/tests/tcp_stream.rs
201
220
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use tokio::io::Interest; use tokio::net::{TcpListener, TcpStream}; use tokio_test::task; use tokio_test::{assert_pending, assert_ready_ok}; use std::io; #[tokio::test] async fn try_read_write() { const DATA: &[u8] = b"this is some data to write to the socket";...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
02b1117dca1c1e1fcc700bff4d6a93c33bfbc7d8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02b1117dca1c1e1fcc700bff4d6a93c33bfbc7d8/tokio/tests/tcp_stream.rs
1
60
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2
let mut writable = task::spawn(client.writable()); assert_ready_ok!(writable.poll()); match client.try_write(DATA) { Ok(n) => written.extend(&DATA[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { break; } Err(e) => panic!("e...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
02b1117dca1c1e1fcc700bff4d6a93c33bfbc7d8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02b1117dca1c1e1fcc700bff4d6a93c33bfbc7d8/tokio/tests/tcp_stream.rs
41
100
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3
if ready.is_read_closed() { return; } else { tokio::task::yield_now().await; } } } #[test] fn buffer_not_included_in_future() { use std::mem; const N: usize = 4096; let fut = async { let stream = TcpStream::connect("127.0.0.1:8080").await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tcp_stream.rs
MIT
02b1117dca1c1e1fcc700bff4d6a93c33bfbc7d8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02b1117dca1c1e1fcc700bff4d6a93c33bfbc7d8/tokio/tests/tcp_stream.rs
81
112
tokio-rs/tokio:tokio/tests/test_clock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use tokio::time::{self, Duration, Instant}; #[tokio::test] async fn resume_lets_time_move_forward_instead_of_resetting_it() { let start = Instant::now(); time::pause(); time::advance(Duration::from_secs(10)).await; let advanced_by_ten_secs = Instant...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/test_clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/test_clock.rs
1
50
tokio-rs/tokio:tokio/tests/thread_pool.rs:1
#![warn(rust_2018_idioms)] use tokio::executor::park::{Park, Unpark}; use tokio::executor::thread_pool::{self, *}; use futures_util::future::poll_fn; use std::cell::Cell; use std::future::Future; use std::pin::Pin; use std::sync::atomic::Ordering::Relaxed; use std::sync::atomic::*; use std::sync::{mpsc, Arc}; use std...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
1
60
tokio-rs/tokio:tokio/tests/thread_pool.rs:2
impl Drop for Never { fn drop(&mut self) { self.0.fetch_add(1, Relaxed); } } let a = num_inc.clone(); let b = num_dec.clone(); let mut pool = Builder::new() .around_worker(move |_, work| { a.fetch_add(1, Relaxed); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
41
100
tokio-rs/tokio:tokio/tests/thread_pool.rs:3
const NUM_THREADS: usize = 10; for _ in 0..1_000 { let num_inc = Arc::new(AtomicUsize::new(0)); let num_dec = Arc::new(AtomicUsize::new(0)); let num_drop = Arc::new(AtomicUsize::new(0)); struct Never(Arc<AtomicUsize>); impl Future for Never { type Output = (); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
81
140
tokio-rs/tokio:tokio/tests/thread_pool.rs:4
// Assert that all the threads spawned let a = num_inc.load(Relaxed); assert_eq!(a, NUM_THREADS); // Assert that all threads shutdown let b = num_dec.load(Relaxed); assert_eq!(a, b); // Assert that the future was dropped let c = num_drop.load(Relaxed); a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
121
180
tokio-rs/tokio:tokio/tests/thread_pool.rs:5
let cnt = cnt.clone(); let tx = tx.clone(); pool.spawn(async move { let num = cnt.fetch_add(1, Relaxed) + 1; if num == NUM { tx.send(()).unwrap(); } }); } rx.recv().unwrap(); // Wait for t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
161
220
tokio-rs/tokio:tokio/tests/thread_pool.rs:6
} }); } rx.recv().unwrap(); // Wait for the pool to shutdown pool.shutdown_now(); } } #[test] fn many_multishot_futures() { use tokio::sync::mpsc; const CHAIN: usize = 200; const CYCLES: usize = 5; const TRACKS: usize = 50; for _ in 0..50 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
201
260
tokio-rs/tokio:tokio/tests/thread_pool.rs:7
// This final task cycles if needed let (mut final_tx, final_rx) = mpsc::channel(10); let mut cycle_tx = start_tx.clone(); let mut rem = CYCLES; pool.spawn(async move { for _ in 0..CYCLES { let msg = chain_rx.recv().await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
241
300
tokio-rs/tokio:tokio/tests/thread_pool.rs:8
fn global_executor_is_configured() { let pool = new_pool(); let (signal_tx, signal_rx) = mpsc::channel(); pool.spawn(async move { tokio::executor::spawn(async move { signal_tx.send(()).unwrap(); }); }); signal_rx.recv().unwrap(); } #[test] fn new_threadpool_is_idle() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
281
340
tokio-rs/tokio:tokio/tests/thread_pool.rs:9
} pool.spawn(Boom(tx)); rx.recv().unwrap(); } #[test] fn multi_threadpool() { use tokio::sync::oneshot; let pool1 = new_pool(); let pool2 = new_pool(); let (tx, rx) = oneshot::channel(); let (done_tx, done_rx) = mpsc::channel(); pool2.spawn(async move { rx.await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
321
380
tokio-rs/tokio:tokio/tests/thread_pool.rs:10
impl Park for MyPark { type Unpark = MyUnpark; type Error = (); fn unpark(&self) -> Self::Unpark { MyUnpark { tx: Mutex::new(self.tx.lock().unwrap().clone()), unpark_tx: self.unpark_tx.clone(), } } fn park(&mut self) -> Re...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
361
420
tokio-rs/tokio:tokio/tests/thread_pool.rs:11
let (tx, rx) = mpsc::channel(); MyPark { tx: Mutex::new(tx), rx, park_tx: park_tx.clone(), unpark_tx: unpark_tx.clone(), } }); struct MyTask { task_tx: Option<mpsc::Sender<Waker>>, drop_tx: mpsc::Sender<()>, } impl Future ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
401
460
tokio-rs/tokio:tokio/tests/thread_pool.rs:12
// Drop the pool, this should result in futures being forcefully dropped. drop(pool); // Make sure `MyPark` and `MyUnpark` were dropped during shutdown. assert_eq!(park_rx.try_recv(), Err(mpsc::TryRecvError::Disconnected)); assert_eq!(unpark_rx.try_recv(), Err(mpsc::TryRecvError::Disconnected)); /...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
441
500
tokio-rs/tokio:tokio/tests/thread_pool.rs:13
self.park_light.store(true, Relaxed); Ok(()) } else { self.park() } } } impl Unpark for MyUnpark { fn unpark(&self) {} } let park_light_1 = Arc::new(AtomicBool::new(false)); let park_light_2 = park_light_1.clone(); let (d...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
481
530
tokio-rs/tokio:tokio/tests/thread_pool.rs:14
cx.waker().wake_by_ref(); Poll::Pending })); done_rx.recv().unwrap(); } fn new_pool() -> ThreadPool { Builder::new().num_threads(4).build() }
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
64c26ab1eee35f1b28d2a942447d771171ded61e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/64c26ab1eee35f1b28d2a942447d771171ded61e/tokio/tests/thread_pool.rs
521
530
tokio-rs/tokio:tokio/tests/thread_pool.rs:1
#![warn(rust_2018_idioms)] use tokio::executor::park::{Park, Unpark}; use tokio::executor::thread_pool::{self, *}; use futures_util::future::poll_fn; use std::cell::Cell; use std::future::Future; use std::pin::Pin; use std::sync::atomic::Ordering::Relaxed; use std::sync::atomic::*; use std::sync::{mpsc, Arc}; use std...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
1
60
tokio-rs/tokio:tokio/tests/thread_pool.rs:2
let a = num_inc.clone(); let b = num_dec.clone(); let mut pool = Builder::new() .around_worker(move |_, work| { a.fetch_add(1, Relaxed); work(); b.fetch_add(1, Relaxed); }) .build(); // let tx = pool.sender().c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
41
100
tokio-rs/tokio:tokio/tests/thread_pool.rs:3
struct Never(Arc<AtomicUsize>); impl Future for Never { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { Poll::Pending } } impl Drop for Never { fn drop(&mut self) { self.0.fetc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
81
140
tokio-rs/tokio:tokio/tests/thread_pool.rs:4
assert_eq!(a, b); // Assert that the future was dropped let c = num_drop.load(Relaxed); assert_eq!(c, 1); } } #[test] fn blocking() { // used for notifying the main thread const NUM: usize = 10_000; for _ in 0..50 { let (tx, rx) = mpsc::channel(); let mut pool...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
121
180
tokio-rs/tokio:tokio/tests/thread_pool.rs:5
if num == NUM { tx.send(()).unwrap(); } }); } rx.recv().unwrap(); // Wait for the pool to shutdown block.wait(); pool.shutdown_now(); } } #[test] fn many_oneshot_futures() { // used for notifying the main thread const...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
161
220
tokio-rs/tokio:tokio/tests/thread_pool.rs:6
// Wait for the pool to shutdown pool.shutdown_now(); } } #[test] fn many_multishot_futures() { use tokio::sync::mpsc; const CHAIN: usize = 200; const CYCLES: usize = 5; const TRACKS: usize = 50; for _ in 0..50 { let pool = new_pool(); let mut start_txs = Vec::with_cap...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
201
260
tokio-rs/tokio:tokio/tests/thread_pool.rs:7
for _ in 0..CYCLES { let msg = chain_rx.recv().await.unwrap(); rem -= 1; if rem == 0 { final_tx.send(msg).await.unwrap(); } else { cycle_tx.send(msg).await.unwrap(); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
241
300
tokio-rs/tokio:tokio/tests/thread_pool.rs:8
tokio::executor::spawn(async move { signal_tx.send(()).unwrap(); }); }); signal_rx.recv().unwrap(); } #[test] fn new_threadpool_is_idle() { let mut pool = new_pool(); pool.shutdown_now(); } #[test] fn panic_in_task() { let pool = new_pool(); let (tx, rx) = mpsc::channel();...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
281
340
tokio-rs/tokio:tokio/tests/thread_pool.rs:9
#[test] fn multi_threadpool() { use tokio::sync::oneshot; let pool1 = new_pool(); let pool2 = new_pool(); let (tx, rx) = oneshot::channel(); let (done_tx, done_rx) = mpsc::channel(); pool2.spawn(async move { rx.await.unwrap(); done_tx.send(()).unwrap(); }); pool1.spaw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
321
380
tokio-rs/tokio:tokio/tests/thread_pool.rs:10
tx: Mutex::new(self.tx.lock().unwrap().clone()), unpark_tx: self.unpark_tx.clone(), } } fn park(&mut self) -> Result<(), Self::Error> { let _ = self.rx.recv(); Ok(()) } fn park_timeout(&mut self, duration: Duration) -> Result<(), Self...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
361
420
tokio-rs/tokio:tokio/tests/thread_pool.rs:11
} }); struct MyTask { task_tx: Option<mpsc::Sender<Waker>>, drop_tx: mpsc::Sender<()>, } impl Future for MyTask { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { if let Some(tx) = self.get_mut().task_tx.take() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
401
460
tokio-rs/tokio:tokio/tests/thread_pool.rs:12
// If the future is forcefully dropped, then we will get a signal here. drop_rx.recv().unwrap(); // Ensure `task` lives until after the test completes. drop(task); } #[test] fn park_called_at_interval() { struct MyPark { park_light: Arc<AtomicBool>, } struct MyUnpark {} impl Park...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
441
500
tokio-rs/tokio:tokio/tests/thread_pool.rs:13
} impl Unpark for MyUnpark { fn unpark(&self) {} } let park_light_1 = Arc::new(AtomicBool::new(false)); let park_light_2 = park_light_1.clone(); let (done_tx, done_rx) = mpsc::channel(); // Use 1 thread to ensure the worker stays busy. let pool = Builder::new().num_threads(1).bui...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
109fd3086b97896c422d9565e7d1ddbe4b6f300b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/109fd3086b97896c422d9565e7d1ddbe4b6f300b/tokio/tests/thread_pool.rs
481
524
tokio-rs/tokio:tokio/tests/thread_pool.rs:1
#![warn(rust_2018_idioms)] use tokio::executor::park::{Park, Unpark}; use tokio::executor::thread_pool::*; use futures_util::future::poll_fn; use std::cell::Cell; use std::future::Future; use std::pin::Pin; use std::sync::atomic::Ordering::Relaxed; use std::sync::atomic::*; use std::sync::{mpsc, Arc}; use std::task::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
1
60
tokio-rs/tokio:tokio/tests/thread_pool.rs:3
struct Never(Arc<AtomicUsize>); impl Future for Never { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { Poll::Pending } } impl Drop for Never { fn drop(&mut self) { self.0.fetc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
81
140
tokio-rs/tokio:tokio/tests/thread_pool.rs:4
assert_eq!(a, b); // Assert that the future was dropped let c = num_drop.load(Relaxed); assert_eq!(c, 1); } } #[test] fn many_oneshot_futures() { // used for notifying the main thread const NUM: usize = 10_000; for _ in 0..50 { let (tx, rx) = mpsc::channel(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
121
180
tokio-rs/tokio:tokio/tests/thread_pool.rs:5
fn many_multishot_futures() { use tokio::sync::mpsc; const CHAIN: usize = 200; const CYCLES: usize = 5; const TRACKS: usize = 50; for _ in 0..50 { let pool = new_pool(); let mut start_txs = Vec::with_capacity(TRACKS); let mut final_rxs = Vec::with_capacity(TRACKS); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
161
220
tokio-rs/tokio:tokio/tests/thread_pool.rs:6
final_tx.send(msg).await.unwrap(); } else { cycle_tx.send(msg).await.unwrap(); } } }); start_txs.push(start_tx); final_rxs.push(final_rx); } { let mut e = tokio::executor::en...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
201
260
tokio-rs/tokio:tokio/tests/thread_pool.rs:7
} #[test] fn new_threadpool_is_idle() { let mut pool = new_pool(); pool.shutdown_now(); } #[test] fn panic_in_task() { let pool = new_pool(); let (tx, rx) = mpsc::channel(); struct Boom(mpsc::Sender<()>); impl Future for Boom { type Output = (); fn poll(self: Pin<&mut Self>,...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
241
300
tokio-rs/tokio:tokio/tests/thread_pool.rs:8
let (tx, rx) = oneshot::channel(); let (done_tx, done_rx) = mpsc::channel(); pool2.spawn(async move { rx.await.unwrap(); done_tx.send(()).unwrap(); }); pool1.spawn(async move { tx.send(()).unwrap(); }); done_rx.recv().unwrap(); } #[test] fn eagerly_drops_futures() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
281
340
tokio-rs/tokio:tokio/tests/thread_pool.rs:9
let _ = self.rx.recv(); Ok(()) } fn park_timeout(&mut self, duration: Duration) -> Result<(), Self::Error> { let _ = self.rx.recv_timeout(duration); Ok(()) } } struct MyUnpark { tx: Mutex<mpsc::Sender<()>>, #[allow(dead_code)] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
321
380
tokio-rs/tokio:tokio/tests/thread_pool.rs:11
} #[test] fn park_called_at_interval() { struct MyPark { park_light: Arc<AtomicBool>, } struct MyUnpark {} impl Park for MyPark { type Unpark = MyUnpark; type Error = (); fn unpark(&self) -> Self::Unpark { MyUnpark {} } fn park(&mut self) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
401
460
tokio-rs/tokio:tokio/tests/thread_pool.rs:12
let park_light_1 = Arc::new(AtomicBool::new(false)); let park_light_2 = park_light_1.clone(); let (done_tx, done_rx) = mpsc::channel(); // Use 1 thread to ensure the worker stays busy. let pool = Builder::new().num_threads(1).build_with_park(move |idx| { assert_eq!(idx, 0); MyPark { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/thread_pool.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/thread_pool.rs
441
478
tokio-rs/tokio:tokio/tests/time_alt.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "time", feature = "rt-multi-thread"))] use tokio::runtime::Runtime; use tokio::time::*; fn rt_combinations() -> Vec<Runtime> { let mut rts = vec![]; let rt = tokio::runtime::Builder::new_multi_thread() .worker_threads(1) .enable_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/time_alt.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_alt.rs
1
60
tokio-rs/tokio:tokio/tests/time_alt.rs:2
} rts } #[test] fn sleep() { const N: u32 = 512; for rt in rt_combinations() { rt.block_on(async { let mut jhs = vec![]; // sleep outside of the worker threads let now = Instant::now(); tokio::time::sleep(Duration::from_millis(10)).await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/time_alt.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_alt.rs
41
100
tokio-rs/tokio:tokio/tests/time_alt.rs:3
rt.block_on(async { let mut jhs = vec![]; // timeout outside of the worker threads let now = Instant::now(); tokio::time::timeout(Duration::from_millis(10), std::future::pending::<()>()) .await .expect_err("timeout should occur"); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/time_alt.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_alt.rs
81
108