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/task_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads
use tokio::{runtime, task};
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
mod support {
pub(crate) mod mpsc_stream;
}
#[tokio::test]
async fn basic_blocking() {
// Run a few time... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:6 | let outer = tokio::runtime::Runtime::new().unwrap();
let (tx, rx) = support::mpsc_stream::unbounded_channel_stream();
for i in 0..200 {
tx.send(i).unwrap();
}
drop(tx);
outer.block_on(async move {
tokio::task::block_in_place(move || {
fu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_blocking.rs | 201 | 228 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:2 | assert_ok!(
task::spawn_blocking(|| {
task::block_in_place(|| {
thread::sleep(Duration::from_millis(5));
});
"hello"
})
.await
)
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/task_blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:3 | task::block_in_place(|| {});
}
#[test]
fn yes_block_in_threaded_block_on() {
let rt = runtime::Runtime::new().unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
}
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
let rt = runtime::Builder::new_current_thread().build().unwra... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/task_blocking.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
use tokio::{runtime, task};
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
mod support {
pub(crate) mod mpsc_stream;
}
#[tokio::test]
async fn basic_blocking() {
// Run a ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::{runtime, task};
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
mod support {
pub(crate) mod mpsc_stream;
}
#[tokio::test]
async fn basic_blocking() {
// Run a few times
for _ in 0..100 {
let out = assert_ok!(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d8b37d51a7d0cdf5a0fbf754240c929fb69e9f2/tokio/tests/task_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:3 | task::block_in_place(|| {});
}
#[test]
fn yes_block_in_threaded_block_on() {
let rt = runtime::Runtime::new().unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
}
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
let rt = runtime::Builder::new_current_thread().build().unwra... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/tests/task_blocking.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:4 | let result = catch_unwind(AssertUnwindSafe(|| {
outer.block_on(async {
let _ = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
});
}));
assert!(result.is_err());
let err = result.unwrap_err();
let err: &'static str = err.down... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/tests/task_blocking.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::{runtime, task};
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
#[tokio::test]
async fn basic_blocking() {
// Run a few times
for _ in 0..100 {
let out = assert_ok!(
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:2 | });
"hello"
})
.await
)
})
.await
);
assert_eq!(out, "hello");
}
}
#[tokio::test(flavor = "multi_thread")]
async fn block_in_block() {
// Run a few times
for _ in 0..100 {
let ou... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:3 | fn yes_block_in_threaded_block_on() {
let rt = runtime::Runtime::new().unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
}
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
let rt = runtime::Builder::new_current_thread().build().unwrap();
rt.block_on(async {
tas... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_blocking.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:4 | .build()
.unwrap();
});
}));
assert!(result.is_err());
let err = result.unwrap_err();
let err: &'static str = err.downcast_ref::<&'static str>().unwrap();
assert!(
err.find("Cannot drop a runtime").is_some(),
"Wrong panic message: {:?}",
err
);
}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_blocking.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:5 | #[test]
fn coop_disabled_in_block_in_place() {
let outer = tokio::runtime::Builder::new_multi_thread()
.enable_time()
.build()
.unwrap();
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
for i in 0..200 {
tx.send(i).unwrap();
}
drop(tx);
outer.block_on(asy... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_blocking.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:6 | }
drop(tx);
outer.block_on(async move {
tokio::task::block_in_place(move || {
futures::executor::block_on(async move {
use tokio::stream::StreamExt;
assert_eq!(rx.fold(0, |n, _| n + 1).await, 200);
})
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_blocking.rs | 201 | 222 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::{runtime, task};
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
#[tokio::test]
async fn basic_blocking() {
// Run a few times
for _ in 0..100 {
let out = assert_ok!(
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/task_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:2 | });
"hello"
})
.await
)
})
.await
);
assert_eq!(out, "hello");
}
}
#[tokio::test(threaded_scheduler)]
async fn block_in_block() {
// Run a few times
for _ in 0..100 {
let out = a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/task_blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:3 | fn yes_block_in_threaded_block_on() {
let rt = runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
}
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
let rt = runtime::Builder::new().basic_schedu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/task_blocking.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:4 | use std::panic::{catch_unwind, AssertUnwindSafe};
let outer = tokio::runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
let result = catch_unwind(AssertUnwindSafe(|| {
outer.block_on(async {
let _ = tokio::runtime::Builder::new()
.basi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/task_blocking.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:5 | });
}
#[test]
fn can_shutdown_now_in_runtime() {
let outer = tokio::runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
outer.block_on(async {
let rt = tokio::runtime::Builder::new()
.basic_scheduler()
.build()
.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/task_blocking.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:6 | })
});
tokio::time::timeout(Duration::from_secs(1), jh)
.await
.expect("timed out (probably hanging)")
.unwrap()
});
}
#[test]
fn coop_disabled_in_block_in_place_in_block_on() {
let (done_tx, done_rx) = std::sync::mpsc::channel();
let done = done_tx.clon... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/task_blocking.rs | 201 | 245 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:2 | });
"hello"
})
.await
)
})
.await
);
assert_eq!(out, "hello");
}
}
#[tokio::test(threaded_scheduler)]
async fn block_in_block() {
// Run a few times
for _ in 0..100 {
let out = a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 0366a3e6d1aa4e7bf4a1c717680dd0947589264b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/tests/task_blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:3 | fn yes_block_in_threaded_block_on() {
let mut rt = runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
}
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
let mut rt = runtime::Builder::new().basi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 0366a3e6d1aa4e7bf4a1c717680dd0947589264b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/tests/task_blocking.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:4 | use std::panic::{catch_unwind, AssertUnwindSafe};
let mut outer = tokio::runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
let result = catch_unwind(AssertUnwindSafe(|| {
outer.block_on(async {
let _ = tokio::runtime::Builder::new()
.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 0366a3e6d1aa4e7bf4a1c717680dd0947589264b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/tests/task_blocking.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:5 | });
}
#[test]
fn can_shutdown_now_in_runtime() {
let mut outer = tokio::runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
outer.block_on(async {
let rt = tokio::runtime::Builder::new()
.basic_scheduler()
.build()
.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 0366a3e6d1aa4e7bf4a1c717680dd0947589264b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/tests/task_blocking.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:6 | })
});
tokio::time::timeout(Duration::from_secs(1), jh)
.await
.expect("timed out (probably hanging)")
.unwrap()
});
}
#[test]
fn coop_disabled_in_block_in_place_in_block_on() {
let (done_tx, done_rx) = std::sync::mpsc::channel();
let done = done_tx.clon... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 0366a3e6d1aa4e7bf4a1c717680dd0947589264b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/tests/task_blocking.rs | 201 | 245 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:4 | use std::panic::{catch_unwind, AssertUnwindSafe};
let mut outer = tokio::runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
let result = catch_unwind(AssertUnwindSafe(|| {
outer.block_on(async {
let _ = tokio::runtime::Builder::new()
.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 04a2826084743e80762a32fcee912a3dfbb86a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/04a2826084743e80762a32fcee912a3dfbb86a63/tokio/tests/task_blocking.rs | 121 | 178 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:5 | });
}
#[test]
fn can_shutdown_now_in_runtime() {
let mut outer = tokio::runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
outer.block_on(async {
let rt = tokio::runtime::Builder::new()
.basic_scheduler()
.build()
.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 04a2826084743e80762a32fcee912a3dfbb86a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/04a2826084743e80762a32fcee912a3dfbb86a63/tokio/tests/task_blocking.rs | 161 | 178 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:3 | fn yes_block_in_threaded_block_on() {
let mut rt = runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
}
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
let mut rt = runtime::Builder::new().basi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/tests/task_blocking.rs | 81 | 117 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:2 | });
"hello"
})
.await
)
})
.await
);
assert_eq!(out, "hello");
}
}
#[tokio::test(threaded_scheduler)]
async fn block_in_block() {
// Run a few times
for _ in 0..100 {
let out = a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 282b00cbe888a96669877ce70662fba87e8c0e3c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/tests/task_blocking.rs | 41 | 98 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:3 | fn yes_block_in_threaded_block_on() {
let mut rt = runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
}
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
let mut rt = runtime::Builder::new().basi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 282b00cbe888a96669877ce70662fba87e8c0e3c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/tests/task_blocking.rs | 81 | 98 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::task;
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
#[tokio::test]
async fn basic_blocking() {
// Run a few times
for _ in 0..100 {
let out = assert_ok!(
tokio::spawn(async {
assert_ok!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | 67c4cc03919a58076c139f0930f28c3c41dad1e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/tests/task_blocking.rs | 1 | 49 |
tokio-rs/tokio:tokio/tests/task_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::task;
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
#[tokio::test]
async fn basic_blocking() {
// Run a few times
for _ in 0..100 {
let out = assert_ok!(
tokio::spawn(async {
assert_ok!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_blocking.rs | MIT | a2cfc877a7f45eb0e1ae8d2775e22ee91da725ec | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a2cfc877a7f45eb0e1ae8d2775e22ee91da725ec/tokio/tests/task_blocking.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/task_builder.rs:1 | #![cfg(all(tokio_unstable, feature = "tracing"))]
use std::rc::Rc;
use tokio::task::{Builder, LocalSet};
#[tokio::test]
async fn spawn_with_name() {
let result = Builder::new()
.name("name")
.spawn(async { "task executed" })
.unwrap()
.await;
assert_eq!(result.unwrap(), "task ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_builder.rs:2 | .unwrap()
.await;
}
#[tokio::test]
async fn spawn_blocking_with_name() {
let result = Builder::new()
.name("name")
.spawn_blocking(|| "task executed")
.unwrap()
.await;
assert_eq!(result.unwrap(), "task executed");
}
#[tokio::test]
async fn spawn_local_with_name() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_builder.rs:3 | #[tokio::test]
async fn spawn_blocking_without_name() {
let result = Builder::new()
.spawn_blocking(|| "task executed")
.unwrap()
.await;
assert_eq!(result.unwrap(), "task executed");
}
#[tokio::test]
async fn spawn_local_without_name() {
let unsend_data = Rc::new("task executed");... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_builder.rs | 81 | 105 |
tokio-rs/tokio:tokio/tests/task_builder.rs:1 | #![cfg(all(tokio_unstable, feature = "tracing"))]
use std::rc::Rc;
use tokio::task::{Builder, LocalSet};
#[tokio::test]
async fn spawn_with_name() {
let result = Builder::new()
.name("name")
.spawn(async { "task executed" })
.unwrap()
.await;
assert_eq!(result.unwrap(), "task ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | acfdb87e2b8b5daa8ffe31de53eaff0df3f04c50 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acfdb87e2b8b5daa8ffe31de53eaff0df3f04c50/tokio/tests/task_builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_builder.rs:2 | assert_eq!(*result.unwrap(), "task executed");
}
#[tokio::test]
async fn spawn_without_name() {
let result = Builder::new()
.spawn(async { "task executed" })
.unwrap()
.await;
assert_eq!(result.unwrap(), "task executed");
}
#[tokio::test]
async fn spawn_blocking_without_name() {
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | acfdb87e2b8b5daa8ffe31de53eaff0df3f04c50 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acfdb87e2b8b5daa8ffe31de53eaff0df3f04c50/tokio/tests/task_builder.rs | 41 | 77 |
tokio-rs/tokio:tokio/tests/task_builder.rs:1 | #![cfg(all(tokio_unstable, feature = "tracing"))]
use std::rc::Rc;
use tokio::{
task::{Builder, LocalSet},
test,
};
#[test]
async fn spawn_with_name() {
let result = Builder::new()
.name("name")
.spawn(async { "task executed" })
.unwrap()
.await;
assert_eq!(result.unwr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_builder.rs:2 | })
.await;
assert_eq!(*result.unwrap(), "task executed");
}
#[test]
async fn spawn_without_name() {
let result = Builder::new()
.spawn(async { "task executed" })
.unwrap()
.await;
assert_eq!(result.unwrap(), "task executed");
}
#[test]
async fn spawn_blocking_without_name... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_builder.rs | 41 | 80 |
tokio-rs/tokio:tokio/tests/task_builder.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![cfg(all(tokio_unstable, feature = "tracing"))]
use std::rc::Rc;
use tokio::{
task::{Builder, LocalSet},
test,
};
#[test]
async fn spawn_with_name() {
let result = Builder::new()
.name("name")
.spawn(async { "task executed" })
.unwrap()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_builder.rs:2 | .await
})
.await;
assert_eq!(*result.unwrap(), "task executed");
}
#[test]
async fn spawn_without_name() {
let result = Builder::new()
.spawn(async { "task executed" })
.unwrap()
.await;
assert_eq!(result.unwrap(), "task executed");
}
#[test]
async fn spawn_blocki... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_builder.rs | 41 | 81 |
tokio-rs/tokio:tokio/tests/task_builder.rs:1 | #[cfg(all(tokio_unstable, feature = "tracing"))]
mod tests {
use std::rc::Rc;
use tokio::{
task::{Builder, LocalSet},
test,
};
#[test]
async fn spawn_with_name() {
let result = Builder::new()
.name("name")
.spawn(async { "task executed" })
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 3b6c74a40ad87837ab53c105a323c2807a4e1b38 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6c74a40ad87837ab53c105a323c2807a4e1b38/tokio/tests/task_builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_builder.rs:2 | })
.await;
assert_eq!(*result.unwrap(), "task executed");
}
#[test]
async fn spawn_without_name() {
let result = Builder::new()
.spawn(async { "task executed" })
.unwrap()
.await;
assert_eq!(result.unwrap(), "task executed");
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 3b6c74a40ad87837ab53c105a323c2807a4e1b38 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6c74a40ad87837ab53c105a323c2807a4e1b38/tokio/tests/task_builder.rs | 41 | 81 |
tokio-rs/tokio:tokio/tests/task_builder.rs:1 | #[cfg(all(tokio_unstable, feature = "tracing"))]
mod tests {
use std::rc::Rc;
use tokio::{
task::{Builder, LocalSet},
test,
};
#[test]
async fn spawn_with_name() {
let result = Builder::new()
.name("name")
.spawn(async { "task executed" })
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 8fa29cb00a486c0ffc28f295c749573cb58a8967 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/tests/task_builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_builder.rs:2 | assert_eq!(*result.unwrap(), "task executed");
}
#[test]
async fn spawn_without_name() {
let result = Builder::new().spawn(async { "task executed" }).await;
assert_eq!(result.unwrap(), "task executed");
}
#[test]
async fn spawn_blocking_without_name() {
let result = Bu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_builder.rs | MIT | 8fa29cb00a486c0ffc28f295c749573cb58a8967 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/tests/task_builder.rs | 41 | 67 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable, target_has_atomic = "64"))]
use std::collections::HashSet;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use tokio::runtime::Builder;
const TASKS: usize = 8;
const ITERATIONS: usize = 64;
/// Assert that the spawn ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_hooks.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:2 | assert_eq!(
TASKS, count_ids_realized,
"Total number of spawned task hook invocations was incorrect, expected {TASKS}, got {count_realized}"
);
}
/// Assert that the terminate task hook always fires when set.
#[test]
fn terminate_task_hook_fires() {
let count = Arc::new(AtomicUsize::new(0));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_hooks.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:3 | let poll_ends = Arc::new(AtomicUsize::new(0));
let runtime = Builder::new_current_thread()
.on_task_spawn(mk_spawn_location_hook(
"(current_thread) on_task_spawn",
&spawns,
))
.on_before_task_poll(mk_spawn_location_hook(
"(current_thread) on_before_task_p... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_hooks.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:4 | /// Testing this separately is necessary as the spawn code paths are different
/// and we should ensure that `#[track_caller]` is passed through correctly
/// for both runtimes.
#[cfg_attr(
target_os = "wasi",
ignore = "WASI does not support multi-threaded runtime"
)]
#[test]
fn task_hook_spawn_location_multi_t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_hooks.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:5 | });
// Give the runtime to shut down so that we see all the expected calls to
// the task hooks.
runtime.shutdown_timeout(std::time::Duration::from_secs(60));
// Note: we "read" the counters using `fetch_add(0, SeqCst)` rather than
// `load(SeqCst)` because read-write-modify operations are guarant... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_hooks.rs | 161 | 194 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable, target_has_atomic = "64"))]
use std::collections::HashSet;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use tokio::runtime::Builder;
const TASKS: usize = 8;
const ITERATIONS: usize = 64;
/// Assert that the spawn ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | a0d5b8ab308bbeaa8090d411550d6c887d699096 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/tests/task_hooks.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:2 | let count_ids_realized = ids.lock().unwrap().len();
assert_eq!(
TASKS, count_ids_realized,
"Total number of spawned task hook invocations was incorrect, expected {TASKS}, got {}",
count_realized
);
}
/// Assert that the terminate task hook always fires when set.
#[test]
fn terminate_ta... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | a0d5b8ab308bbeaa8090d411550d6c887d699096 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/tests/task_hooks.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:3 | let spawns = Arc::new(AtomicUsize::new(0));
let poll_starts = Arc::new(AtomicUsize::new(0));
let poll_ends = Arc::new(AtomicUsize::new(0));
let runtime = Builder::new_current_thread()
.on_task_spawn(mk_spawn_location_hook(
"(current_thread) on_task_spawn",
&spawns,
)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | a0d5b8ab308bbeaa8090d411550d6c887d699096 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/tests/task_hooks.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:4 | /// multi-thread runtime.
///
/// Testing this separately is necessary as the spawn code paths are different
/// and we should ensure that `#[track_caller]` is passed through correctly
/// for both runtimes.
#[cfg_attr(
target_os = "wasi",
ignore = "WASI does not support multi-threaded runtime"
)]
#[test]
fn ta... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | a0d5b8ab308bbeaa8090d411550d6c887d699096 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/tests/task_hooks.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:5 | tokio::task::yield_now().await;
}
});
// Give the runtime to shut down so that we see all the expected calls to
// the task hooks.
runtime.shutdown_timeout(std::time::Duration::from_secs(60));
// Note: we "read" the counters using `fetch_add(0, SeqCst)` rather than
// `load(SeqCst)` be... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | a0d5b8ab308bbeaa8090d411550d6c887d699096 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/tests/task_hooks.rs | 161 | 196 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:3 | let spawns = Arc::new(AtomicUsize::new(0));
let poll_starts = Arc::new(AtomicUsize::new(0));
let poll_ends = Arc::new(AtomicUsize::new(0));
let runtime = Builder::new_current_thread()
.on_task_spawn(mk_spawn_location_hook(
"(current_thread) on_task_spawn",
&spawns,
)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/tests/task_hooks.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:4 | /// for both runtimes.
#[cfg_attr(
target_os = "wasi",
ignore = "WASI does not support multi-threaded runtime"
)]
#[test]
fn task_hook_spawn_location_multi_thread() {
let spawns = Arc::new(AtomicUsize::new(0));
let poll_starts = Arc::new(AtomicUsize::new(0));
let poll_ends = Arc::new(AtomicUsize::ne... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/tests/task_hooks.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:5 | // Note: we "read" the counters using `fetch_add(0, SeqCst)` rather than
// `load(SeqCst)` because read-write-modify operations are guaranteed to
// observe the latest value, while the load is not.
// This avoids a race that may cause test flakiness.
assert_eq!(spawns.fetch_add(0, Ordering::SeqCst), 1);... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/tests/task_hooks.rs | 161 | 189 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:2 | let count_ids_realized = ids.lock().unwrap().len();
assert_eq!(
TASKS, count_ids_realized,
"Total number of spawned task hook invocations was incorrect, expected {TASKS}, got {}",
count_realized
);
}
/// Assert that the terminate task hook always fires when set.
#[test]
fn terminate_ta... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_hooks.rs | 41 | 75 |
tokio-rs/tokio:tokio/tests/task_hooks.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable, target_has_atomic = "64"))]
use std::collections::HashSet;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use tokio::runtime::Builder;
const TASKS: usize = 8;
const ITERATIO... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_hooks.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/tests/task_hooks.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_id.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::error::Error;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::runtime::Runtime;
use tokio::sync::oneshot;
use tokio::task::{self, Id, LocalSet};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[to... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_id.rs:2 | #[cfg(not(target_os = "wasi"))]
#[tokio::test(flavor = "multi_thread")]
async fn task_id_collision_multi_thread() {
let handle1 = tokio::spawn(async { task::id() });
let handle2 = tokio::spawn(async { task::id() });
let (id1, id2) = tokio::join!(handle1, handle2);
assert_ne!(id1.unwrap(), id2.unwrap())... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_id.rs:3 | impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Ready(())
}
}
impl Drop for MyFuture {
fn drop(&mut self) {
let _ = self.tx.take().unwrap().send(task::id());
}
}
let (... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_id.rs:4 | let (tx, rx) = oneshot::channel();
let handle = tokio::spawn(MyFuture { tx: Some(tx) });
let id = handle.id();
handle.abort();
assert!(handle.await.unwrap_err().is_cancelled());
assert_eq!(rx.await.unwrap(), id);
}
#[tokio::test(flavor = "current_thread")]
async fn task_id_output_destructor_handle_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_id.rs:5 | #[tokio::test(flavor = "current_thread")]
async fn task_id_output_destructor_handle_dropped_after_completion() {
struct MyOutput {
tx: Option<oneshot::Sender<Id>>,
}
impl Drop for MyOutput {
fn drop(&mut self) {
let _ = self.tx.take().unwrap().send(task::id());
}
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_id.rs:6 | }
#[test]
fn task_try_id_outside_task() {
assert_eq!(None, task::try_id());
}
#[cfg(not(target_os = "wasi"))]
#[test]
fn task_try_id_inside_block_on() {
let rt = Runtime::new().unwrap();
rt.block_on(async {
assert_eq!(None, task::try_id());
});
}
#[tokio::test(flavor = "current_thread")]
asyn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/task_id.rs:7 | })
.await;
assert_eq!(parent_id, task::id());
})
.await
.unwrap();
})
.await;
}
#[cfg(not(target_os = "wasi"))]
#[tokio::test(flavor = "multi_thread")]
async fn task_id_block_in_place_block_on_spawn() {
use tokio::runtime::Buil... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/task_id.rs:8 | assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn task_id_inside_block_on_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = Runtime::new().unwrap();
rt.block_on(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_id.rs | 281 | 300 |
tokio-rs/tokio:tokio/tests/task_id.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::error::Error;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::runtime::Runtime;
use tokio::sync::oneshot;
use tokio::task::{self, Id, LocalSet};
mod support {
pub mod pani... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_id.rs:2 | #[cfg(not(target_os = "wasi"))]
#[tokio::test(flavor = "multi_thread")]
async fn task_id_collision_multi_thread() {
let handle1 = tokio::spawn(async { task::id() });
let handle2 = tokio::spawn(async { task::id() });
let (id1, id2) = tokio::join!(handle1, handle2);
assert_ne!(id1.unwrap(), id2.unwrap())... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_id.rs:3 | impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Ready(())
}
}
impl Drop for MyFuture {
fn drop(&mut self) {
let _ = self.tx.take().unwrap().send(task::id());
}
}
let (... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_id.rs:4 | }
let (tx, rx) = oneshot::channel();
let handle = tokio::spawn(MyFuture { tx: Some(tx) });
let id = handle.id();
handle.abort();
assert!(handle.await.unwrap_err().is_cancelled());
assert_eq!(rx.await.unwrap(), id);
}
#[tokio::test(flavor = "current_thread")]
async fn task_id_output_destructor_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_id.rs:5 | }
#[tokio::test(flavor = "current_thread")]
async fn task_id_output_destructor_handle_dropped_after_completion() {
struct MyOutput {
tx: Option<oneshot::Sender<Id>>,
}
impl Drop for MyOutput {
fn drop(&mut self) {
let _ = self.tx.take().unwrap().send(task::id());
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_id.rs:6 | assert_eq!(rx_output.await.unwrap(), id);
}
#[test]
fn task_try_id_outside_task() {
assert_eq!(None, task::try_id());
}
#[cfg(not(target_os = "wasi"))]
#[test]
fn task_try_id_inside_block_on() {
let rt = Runtime::new().unwrap();
rt.block_on(async {
assert_eq!(None, task::try_id());
});
}
#[to... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/task_id.rs:7 | .unwrap();
})
.await;
assert_eq!(parent_id, task::id());
})
.await
.unwrap();
})
.await;
}
#[cfg(not(target_os = "wasi"))]
#[tokio::test(flavor = "multi_thread")]
async fn task_id_block_in_place_block_on_spawn()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/task_id.rs:8 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn task_id_inside_block_on_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = Runtime::new().u... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | b68f5c7f38b821b01d148027a03a0dbc177932ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b68f5c7f38b821b01d148027a03a0dbc177932ee/tokio/tests/task_id.rs | 281 | 301 |
tokio-rs/tokio:tokio/tests/task_id.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable))]
#[cfg(not(target_os = "wasi"))]
use std::error::Error;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
#[cfg(not(target_os = "wasi"))]
use tokio::runtime::{Builder, Runtime};
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_id.rs:2 | let (id1, id2) = tokio::join!(handle1, handle2);
assert_ne!(id1.unwrap(), id2.unwrap());
}
#[cfg(not(target_os = "wasi"))]
#[tokio::test(flavor = "multi_thread")]
async fn task_id_collision_multi_thread() {
let handle1 = tokio::spawn(async { task::id() });
let handle2 = tokio::spawn(async { task::id() });
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_id.rs:3 | async fn task_id_future_destructor_completion() {
struct MyFuture {
tx: Option<oneshot::Sender<Id>>,
}
impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Ready(())
}
}
impl Drop for MyFu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_id.rs:4 | impl Drop for MyFuture {
fn drop(&mut self) {
let _ = self.tx.take().unwrap().send(task::id());
}
}
let (tx, rx) = oneshot::channel();
let handle = tokio::spawn(MyFuture { tx: Some(tx) });
let id = handle.id();
handle.abort();
assert!(handle.await.unwrap_err().is_can... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_id.rs:5 | let id = handle.id();
drop(handle);
assert!(rx.try_recv().is_err());
assert_eq!(rx.await.unwrap(), id);
}
#[tokio::test(flavor = "current_thread")]
async fn task_id_output_destructor_handle_dropped_after_completion() {
struct MyOutput {
tx: Option<oneshot::Sender<Id>>,
}
impl Drop for ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_id.rs:6 | let id = handle.id();
rx_future.await.unwrap();
assert!(rx_output.try_recv().is_err());
drop(handle);
assert_eq!(rx_output.await.unwrap(), id);
}
#[test]
fn task_try_id_outside_task() {
assert_eq!(None, task::try_id());
}
#[cfg(not(target_os = "wasi"))]
#[test]
fn task_try_id_inside_block_on() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/task_id.rs:7 | task::spawn_local(async move {
assert_ne!(parent_id, task::id());
})
.await
.unwrap();
})
.await;
assert_eq!(parent_id, task::id());
})
.awa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/task_id.rs:8 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[cfg(not(target_os = "wasi"))]
#[test]
fn task_id_inside_block_on_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = Runtime::new().unw... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_id.rs | 281 | 303 |
tokio-rs/tokio:tokio/tests/task_id.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable))]
#[cfg(not(target_os = "wasi"))]
use std::error::Error;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
#[cfg(not(target_os = "wasi"))]
use tokio::runtime::{Builder, Runtime};
use tokio::sync::oneshot;
use tokio::task:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_id.rs:2 | let (id1, id2) = tokio::join!(handle1, handle2);
assert_ne!(id1.unwrap(), id2.unwrap());
}
#[cfg(not(target_os = "wasi"))]
#[tokio::test(flavor = "multi_thread")]
async fn task_id_collision_multi_thread() {
let handle1 = tokio::spawn(async { task::id() });
let handle2 = tokio::spawn(async { task::id() });
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_id.rs:3 | struct MyFuture {
tx: Option<oneshot::Sender<Id>>,
}
impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Ready(())
}
}
impl Drop for MyFuture {
fn drop(&mut self) {
let _ ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_id.rs:4 | fn drop(&mut self) {
let _ = self.tx.take().unwrap().send(task::id());
}
}
let (tx, rx) = oneshot::channel();
let handle = tokio::spawn(MyFuture { tx: Some(tx) });
let id = handle.id();
handle.abort();
assert!(handle.await.unwrap_err().is_cancelled());
assert_eq!(rx.awai... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/task_id.rs:5 | drop(handle);
assert!(rx.try_recv().is_err());
assert_eq!(rx.await.unwrap(), id);
}
#[tokio::test(flavor = "current_thread")]
async fn task_id_output_destructor_handle_dropped_after_completion() {
struct MyOutput {
tx: Option<oneshot::Sender<Id>>,
}
impl Drop for MyOutput {
fn drop... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_id.rs:6 | rx_future.await.unwrap();
assert!(rx_output.try_recv().is_err());
drop(handle);
assert_eq!(rx_output.await.unwrap(), id);
}
#[test]
fn task_try_id_outside_task() {
assert_eq!(None, task::try_id());
}
#[cfg(not(target_os = "wasi"))]
#[test]
fn task_try_id_inside_block_on() {
let rt = Runtime::new()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/task_id.rs:7 | assert_ne!(parent_id, task::id());
})
.await
.unwrap();
})
.await;
assert_eq!(parent_id, task::id());
})
.await
.unwrap();
})
.await;
}
#[c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/task_id.rs:8 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[cfg(not(target_os = "wasi"))]
#[test]
fn task_id_inside_block_on_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = Runtime::new().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/task_id.rs | 281 | 302 |
tokio-rs/tokio:tokio/tests/task_id.rs:1 | #![warn(rust_2018_idioms)]
#![allow(clippy::declare_interior_mutable_const)]
#![cfg(all(feature = "full", tokio_unstable))]
#[cfg(not(target_os = "wasi"))]
use std::error::Error;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
#[cfg(not(target_os = "wasi"))]
use tokio::runtime::{Builder, Ru... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/task_id.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_id.rs:1 | #![warn(rust_2018_idioms)]
#![allow(clippy::declare_interior_mutable_const)]
#![cfg(all(feature = "full", tokio_unstable))]
#[cfg(not(tokio_wasi))]
use std::error::Error;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
#[cfg(not(tokio_wasi))]
use tokio::runtime::{Builder, Runtime};
use toki... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/tests/task_id.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/task_id.rs:2 | let (id1, id2) = tokio::join!(handle1, handle2);
assert_ne!(id1.unwrap(), id2.unwrap());
}
#[cfg(not(tokio_wasi))]
#[tokio::test(flavor = "multi_thread")]
async fn task_id_collision_multi_thread() {
let handle1 = tokio::spawn(async { task::id() });
let handle2 = tokio::spawn(async { task::id() });
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/tests/task_id.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/task_id.rs:3 | async fn task_id_future_destructor_completion() {
struct MyFuture {
tx: Option<oneshot::Sender<Id>>,
}
impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Ready(())
}
}
impl Drop for MyFu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/tests/task_id.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/task_id.rs:5 | let id = handle.id();
drop(handle);
assert!(rx.try_recv().is_err());
assert_eq!(rx.await.unwrap(), id);
}
#[tokio::test(flavor = "current_thread")]
async fn task_id_output_destructor_handle_dropped_after_completion() {
struct MyOutput {
tx: Option<oneshot::Sender<Id>>,
}
impl Drop for ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/tests/task_id.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/task_id.rs:6 | let id = handle.id();
rx_future.await.unwrap();
assert!(rx_output.try_recv().is_err());
drop(handle);
assert_eq!(rx_output.await.unwrap(), id);
}
#[test]
fn task_try_id_outside_task() {
assert_eq!(None, task::try_id());
}
#[cfg(not(tokio_wasi))]
#[test]
fn task_try_id_inside_block_on() {
let r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/tests/task_id.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/task_id.rs:7 | task::spawn_local(async move {
assert_ne!(parent_id, task::id());
})
.await
.unwrap();
})
.await;
assert_eq!(parent_id, task::id());
})
.awa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/tests/task_id.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/task_id.rs:8 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[cfg(not(tokio_wasi))]
#[test]
fn task_id_inside_block_on_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = Runtime::new().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/task_id.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/tests/task_id.rs | 281 | 303 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.