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_local_set.rs:14
.await; } #[tokio::test] async fn acquire_mutex_in_drop() { use futures::future::pending; let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async move { let _ = rx2.await; unreachable!(); }); local.spa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
b7812c85ca2d051d47cec023b880cbf8cdcbc313
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = local.run_until(pending::<()>()).fuse() => unreachable!(), ret = async { local.spawn_local(ready(())).await.unwrap()}.fuse() => ret } } #[test] fn store_local_set_in_thread_local_with_runtime() { use t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
b7812c85ca2d051d47cec023b880cbf8cdcbc313
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:16
fn method(&self) { self.rt.block_on(self.inner_method()); } } CURRENT.with(|f| { f.method(); }); } #[cfg(tokio_unstable)] mod unstable { use tokio::runtime::UnhandledPanic; use tokio::task::LocalSet; #[tokio::test] #[should_panic( expected = "a spawned ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
b7812c85ca2d051d47cec023b880cbf8cdcbc313
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/tests/task_local_set.rs
601
660
tokio-rs/tokio:tokio/tests/task_local_set.rs:17
// Consume some budget tokio::task::consume_budget().await; LocalSet::new() .run_until(async { let spawned = tokio::spawn(async { let mut spawned_n = 0; { let mut spawned = tokio_test::task::spawn(async { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
b7812c85ca2d051d47cec023b880cbf8cdcbc313
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/tests/task_local_set.rs
641
689
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
.await; } #[tokio::test] async fn acquire_mutex_in_drop() { use futures::future::pending; let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async move { let _ = rx2.await; unreachable!(); }); local.spa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
ca8e176ce98d2372c24c74839877189cbc9883dc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca8e176ce98d2372c24c74839877189cbc9883dc/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = local.run_until(pending::<()>()).fuse() => unreachable!(), ret = async { local.spawn_local(ready(())).await.unwrap()}.fuse() => ret } } #[cfg(tokio_unstable)] mod unstable { use tokio::runtime::Unhandl...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
ca8e176ce98d2372c24c74839877189cbc9883dc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca8e176ce98d2372c24c74839877189cbc9883dc/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:16
LocalSet::new() .run_until(async { let spawned = tokio::spawn(async { let mut spawned_n = 0; { let mut spawned = tokio_test::task::spawn(async { loop { spawned_n += 1;...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
ca8e176ce98d2372c24c74839877189cbc9883dc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca8e176ce98d2372c24c74839877189cbc9883dc/tokio/tests/task_local_set.rs
601
647
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = local.run_until(pending::<()>()).fuse() => unreachable!(), ret = async { local.spawn_local(ready(())).await.unwrap()}.fuse() => ret } } #[cfg(tokio_unstable)] mod unstable { use tokio::runtime::Unhandl...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
57e08e714754420f8b3d8ffe863549d8acf761d0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/tests/task_local_set.rs
561
597
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); task::spawn_local(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
let rt = runtime::Runtime::new().unwrap(); let local = LocalSet::new(); local.block_on(&rt, async move { let (tx, rx) = oneshot::channel(); let join = task::spawn_local(async move { println!("hello world running..."); assert!( ON_RT_THREAD.with(|cell| cell...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
// holds runtime thread until end of main fn. let (_tx, rx) = oneshot::channel::<()>(); let handle = tokio::runtime::Handle::current(); std::thread::spawn(move || { LOCAL_SET.with(|local_set| { handle.block_on(local_set.run_until(async move { let _ = rx.await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
assert_eq!(1, Rc::strong_count(&rc1)); } /// Runs a test function in a separate thread, and panics if the test does not /// complete within the specified timeout, or if the test function panics. /// /// This is intended for running tests whose failure mode is a hang or infinite /// loop that cannot be detected otherwi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
// Test completed successfully! Ok(()) => {} } thread.join().expect("test thread should not panic!") } #[cfg_attr(tokio_wasi, ignore = "`unwrap()` in `with_timeout()` panics on Wasi")] #[test] fn drop_cancels_remote_tasks() { // This test reproduces issue #1885. with_timeout(Duration::from_sec...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
let rt = rt(); let set = LocalSet::new(); let mut handles = Vec::new(); for _ in 1..=128 { handles.push(set.spawn_local(async move { tokio::task::spawn_local(async move {}).await.unwrap(); })); } rt.block_on(set.run_until(join_all(handles...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
RX1.store(0, SeqCst); RX2.store(0, SeqCst); let (tx, mut rx) = mpsc::unbounded_channel(); let local = LocalSet::new(); local .run_until(async { let task2 = task::spawn(async move { // Wait a bit time::sleep(Duration::from_millis(10)).await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
task::spawn_local(async move { oneshot.await.unwrap(); RX2.fetch_add(1, SeqCst); }); } task2.await.unwrap(); }) .await; } #[tokio::test] async fn acquire_mutex_in_drop() { use futures::future::pending; let (tx1, r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
}) .await; // Drop the LocalSet drop(local); } #[tokio::test] async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = local.run_until(pending::<()>()).fuse() => unreachable!(), ret = async { local.spawn_local(ready(())).await.unwrap()}.fuse() => re...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/tests/task_local_set.rs
561
605
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
let rt = runtime::Runtime::new().unwrap(); let local = LocalSet::new(); local.block_on(&rt, async move { let (tx, rx) = oneshot::channel(); let join = task::spawn_local(async move { println!("hello world running..."); assert!( ON_RT_THREAD.with(|cell| cell...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
let rc2 = rc1.clone(); let (started_tx, started_rx) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async move { // Move this in let _rc2 = rc2; started_tx.send(()).unwrap(); futures::future::pending::<()>().await; }); local.block_on(&rt, asyn...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
// something we can easily make assertions about, we'll run it in a // thread. When the test thread finishes, it will send a message on a // channel to this thread. We'll wait for that message with a fairly // generous timeout, and if we don't receive it, we assume the test // thread has hung. // ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
drop(tx); // This enters an infinite loop if the remote notified tasks are not // properly cancelled. drop(local); }); } #[cfg_attr( tokio_wasi, ignore = "FIXME: `task::spawn_local().await.unwrap()` panics on Wasi" )] #[test] fn local_tasks_wake_join_all() { // This test reprod...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
if res.is_ok() { // success return; } } // Test failed 4 times. Try one more time without catching panics. If it // fails again, the test fails. local_tasks_are_polled_after_tick_inner(); } #[cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery #[tokio::main(fla...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
} time::sleep(Duration::from_millis(10)).await; for tx in oneshots.drain(..) { tx.send(()).unwrap(); } time::sleep(Duration::from_millis(20)).await; let rx1 = RX1.load(SeqCst); let rx2 = RX2.load(SeqCs...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
unreachable!(); }); local.spawn_local(async move { let _ = rx1.await; tx2.send(()).unwrap(); unreachable!(); }); // Spawn a task that will never notify local.spawn_local(async move { pending::<()>().await; tx1.send(()).unwrap(); }); // Tick the loop...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
#[tokio::test] #[should_panic( expected = "a spawned task panicked and the LocalSet is configured to shutdown on unhandled panic" )] async fn shutdown_on_panic() { LocalSet::new() .unhandled_panic(UnhandledPanic::ShutdownRuntime) .run_until(async { tok...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/task_local_set.rs
561
584
tokio-rs/tokio:tokio/tests/task_local_set.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use futures::{ future::{pending, ready}, FutureExt, }; use tokio::runtime; use tokio::sync::{mpsc, oneshot}; use tokio::task::{self, LocalSet}; use tokio::time; #[cfg(not(tokio_wasi))] use std::cell::Cell; use std::sync::atomic::AtomicBool; #[cfg(not(tokio...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use futures::{ future::{pending, ready}, FutureExt, }; use tokio::runtime; use tokio::sync::{mpsc, oneshot}; use tokio::task::{self, LocalSet}; use tokio::time; #[cfg(not(target_os = "wasi"))] use std::cell::Cell; use std::sync::atomic::AtomicBool; #[cfg(n...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); task::spawn_local(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
// something we can easily make assertions about, we'll run it in a // thread. When the test thread finishes, it will send a message on a // channel to this thread. We'll wait for that message with a fairly // generous timeout, and if we don't receive it, we assume the test // thread has hung. // ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
local.block_on(&rt, async { time::sleep(Duration::from_millis(1)).await; }); drop(tx); // This enters an infinite loop if the remote notified tasks are not // properly cancelled. drop(local); }); } #[cfg_attr( target_os = "wasi", ignore = "FIXME: `task:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
// This test depends on timing, so we run it up to five times. for _ in 0..4 { let res = std::panic::catch_unwind(local_tasks_are_polled_after_tick_inner); if res.is_ok() { // success return; } } // Test failed 4 times. Try one more time without catching pani...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
let (oneshot_tx, oneshot_rx) = oneshot::channel(); oneshots.push(oneshot_tx); tx.send(oneshot_rx).unwrap(); } time::sleep(Duration::from_millis(10)).await; for tx in oneshots.drain(..) { tx.send(()).unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
local.spawn_local(async move { let _ = rx2.await; unreachable!(); }); local.spawn_local(async move { let _ = rx1.await; tx2.send(()).unwrap(); unreachable!(); }); // Spawn a task that will never notify local.spawn_local(async move { pending::<()>().a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
use tokio::runtime::UnhandledPanic; use tokio::task::LocalSet; #[tokio::test] #[should_panic( expected = "a spawned task panicked and the LocalSet is configured to shutdown on unhandled panic" )] async fn shutdown_on_panic() { LocalSet::new() .unhandled_panic(UnhandledPa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/tests/task_local_set.rs
561
587
tokio-rs/tokio:tokio/tests/task_local_set.rs:3
local.spawn_local(async move { time::sleep(Duration::from_millis(10)).await; RAN2.store(true, Ordering::SeqCst); }); local.await; assert!(RAN1.load(Ordering::SeqCst)); assert!(RAN2.load(Ordering::SeqCst)); } #[tokio::test] async fn localset_future_drives_all_local_futs() { static RA...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
81
140
tokio-rs/tokio:tokio/tests/task_local_set.rs:4
static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); let join = task::spawn_local(async move { assert!(ON_RT_THREAD.with(|cell| cell....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
}); join.await.unwrap(); }); } #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn local_threadpool_blocking_run() { thread_local! { static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
} ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); let handles = (0..128) .map(|_| { task::spawn_local(async { assert!(ON_RT_THREAD.with(|cell|...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
201
260
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
assert!(ON_RT_THREAD.with(|cell| cell.get())); }) .await .unwrap(); }) .await .unwrap(); }) .await .unwrap(); }) .aw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
}); let join2 = task::spawn(async move { assert!( !ON_RT_THREAD.with(|cell| cell.get()), "spawned task should be on a worker" ); tx.send(()).expect("task shouldn't have ended yet"); println!("waking up hello world..."); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
}); drop(local); drop(rt); assert_eq!(1, Rc::strong_count(&rc1)); } /// Runs a test function in a separate thread, and panics if the test does not /// complete within the specified timeout, or if the test function panics. /// /// This is intended for running tests whose failure mode is a hang or infinite ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
// with it. Err(RecvTimeoutError::Disconnected) => { println!("done_rx dropped, did the test thread panic?"); } // Test completed successfully! Ok(()) => {} } thread.join().expect("test thread should not panic!") } #[cfg_attr( target_os = "wasi", ignore = "`...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
#[tokio::main(flavor = "current_thread")] async fn local_tasks_are_polled_after_tick_inner() { // Reproduces issues #1899 and #1900 static RX1: AtomicUsize = AtomicUsize::new(0); static RX2: AtomicUsize = AtomicUsize::new(0); const EXPECTED: usize = 500; RX1.store(0, SeqCst); RX2.store(0, SeqC...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
assert_eq!(EXPECTED, rx1); assert_eq!(EXPECTED, rx2); }); while let Some(oneshot) = rx.recv().await { RX1.fetch_add(1, SeqCst); task::spawn_local(async move { oneshot.await.unwrap(); RX2.fetch_add(1, SeqCst...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
tx1.send(()).unwrap(); }); // Tick the loop local .run_until(async { task::yield_now().await; }) .await; // Drop the LocalSet drop(local); } #[tokio::test] async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = loc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
521
572
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
futures::future::pending::<()>().await; }) .await; } } fn rt() -> runtime::Runtime { tokio::runtime::Builder::new_current_thread() .enable_all() .build() .unwrap() }
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local_set.rs
561
572
tokio-rs/tokio:tokio/tests/task_local_set.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use futures::{ future::{pending, ready}, FutureExt, }; use tokio::runtime::{self, Runtime}; use tokio::sync::{mpsc, oneshot}; use tokio::task::{self, LocalSet}; use tokio::time; use std::cell::Cell; use std::sync::atomic::Ordering::{self, SeqCst}; use std:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
}) .await .unwrap(); }) .await; } #[tokio::test(flavor = "multi_thread")] async fn localset_future_threadpool() { thread_local! { static ON_LOCAL_THREAD: Cell<bool> = Cell::new(false); } ON_LOCAL_THREAD.with(|cell| cell.set(true)); let local = LocalSet:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
41
100
tokio-rs/tokio:tokio/tests/task_local_set.rs:3
#[tokio::test] async fn localset_future_drives_all_local_futs() { static RAN1: AtomicBool = AtomicBool::new(false); static RAN2: AtomicBool = AtomicBool::new(false); static RAN3: AtomicBool = AtomicBool::new(false); let local = LocalSet::new(); local.spawn_local(async move { task::spawn_loc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
81
140
tokio-rs/tokio:tokio/tests/task_local_set.rs:4
assert!(ON_RT_THREAD.with(|cell| cell.get())); time::sleep(Duration::from_millis(10)).await; assert!(ON_RT_THREAD.with(|cell| cell.get())); }); join.await.unwrap(); }) .await; } #[test] // This will panic, since the thread that calls `block_on` ca...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); let join = task::spawn_local(async move { assert!(ON_RT_THREAD.with(|cell| cell.get())); task::spawn_blocking(|| { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
}) .collect::<Vec<_>>(); for joined in future::join_all(handles).await { joined.unwrap(); } }) .await; } #[tokio::test(flavor = "multi_thread")] async fn nested_spawn_is_local() { thread_local! { static ON_RT_THREAD: Cell<bool> = Cell:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
201
260
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
}) .await; } #[test] fn join_local_future_elsewhere() { thread_local! { static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); let rt = runtime::Runtime::new().unwrap(); let local = LocalSet::new(); local.block_on(&rt, async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
join2.await.unwrap() }); } #[test] fn drop_cancels_tasks() { use std::rc::Rc; // This test reproduces issue #1842 let rt = rt(); let rc1 = Rc::new(()); let rc2 = rc1.clone(); let (started_tx, started_rx) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async m...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
let (done_tx, done_rx) = std::sync::mpsc::channel(); let thread = std::thread::spawn(move || { f(); // Send a message on the channel so that the test thread can // determine if we have entered an infinite loop: done_tx.send(()).unwrap(); }); // Since the failure mode of thi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
with_timeout(Duration::from_secs(60), || { let (tx, mut rx) = mpsc::channel::<()>(1024); let rt = rt(); let local = LocalSet::new(); local.spawn_local(async move { while rx.recv().await.is_some() {} }); local.block_on(&rt, async { time::sleep(Duration::from_millis(1...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
#[test] fn local_tasks_are_polled_after_tick() { // This test depends on timing, so we run it up to five times. for _ in 0..4 { let res = std::panic::catch_unwind(local_tasks_are_polled_after_tick_inner); if res.is_ok() { // success return; } } // Test fa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
for _ in 0..EXPECTED { let (oneshot_tx, oneshot_rx) = oneshot::channel(); oneshots.push(oneshot_tx); tx.send(oneshot_rx).unwrap(); } time::sleep(Duration::from_millis(10)).await; for tx in oneshots.drain(..) { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
let local = LocalSet::new(); local.spawn_local(async move { let _ = rx2.await; unreachable!(); }); local.spawn_local(async move { let _ = rx1.await; tx2.send(()).unwrap(); unreachable!(); }); // Spawn a task that will never notify local.spawn_local(asyn...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
mod unstable { use tokio::runtime::UnhandledPanic; use tokio::task::LocalSet; #[tokio::test] #[should_panic( expected = "a spawned task panicked and the LocalSet is configured to shutdown on unhandled panic" )] async fn shutdown_on_panic() { LocalSet::new() .unhandle...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/tests/task_local_set.rs
521
548
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
let local = LocalSet::new(); local.spawn_local(async move { let _ = rx2.await; unreachable!(); }); local.spawn_local(async move { let _ = rx1.await; tx2.send(()).unwrap(); unreachable!(); }); // Spawn a task that will never notify local.spawn_local(asyn...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d39c9ed9dc29627ce3f2e134502ee24b4b537a04
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d39c9ed9dc29627ce3f2e134502ee24b4b537a04/tokio/tests/task_local_set.rs
481
525
tokio-rs/tokio:tokio/tests/task_local_set.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use futures::{ future::{pending, ready}, FutureExt, }; use tokio::runtime::{self, Runtime}; use tokio::sync::{mpsc, oneshot}; use tokio::task::{self, LocalSet}; use tokio::time; use std::cell::Cell; use std::sync::atomic::Ordering::{self, SeqCst}; use std:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); task::spawn_local(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
41
100
tokio-rs/tokio:tokio/tests/task_local_set.rs:3
RAN1.store(true, Ordering::SeqCst); }); local.spawn_local(async move { time::sleep(Duration::from_millis(10)).await; RAN2.store(true, Ordering::SeqCst); }); local.await; assert!(RAN1.load(Ordering::SeqCst)); assert!(RAN2.load(Ordering::SeqCst)); } #[tokio::test] async fn localse...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
81
140
tokio-rs/tokio:tokio/tests/task_local_set.rs:4
thread_local! { static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); let join = task::spawn_local(async move { assert!(ON_RT_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
}); join.await.unwrap(); }); } #[tokio::test(flavor = "multi_thread")] async fn local_threadpool_blocking_run() { thread_local! { static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); let handles = (0..128) .map(|_| { task::spawn_local(async { assert!(ON_RT_THREAD.with(|cell| cell.g...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
201
260
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
.unwrap(); }) .await .unwrap(); }) .await .unwrap(); }) .await .unwrap(); }) .await; } #[test] fn join_local_future_elsewhere() { thread_local! { s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
"spawned task should be on a worker" ); tx.send(()).expect("task shouldn't have ended yet"); println!("waking up hello world..."); join.await.expect("task should complete successfully"); println!("hello world task joined"); }); join2.await.u...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
assert_eq!(1, Rc::strong_count(&rc1)); } /// Runs a test function in a separate thread, and panics if the test does not /// complete within the specified timeout, or if the test function panics. /// /// This is intended for running tests whose failure mode is a hang or infinite /// loop that cannot be detected otherwi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
// Test completed successfully! Ok(()) => {} } thread.join().expect("test thread should not panic!") } #[test] fn drop_cancels_remote_tasks() { // This test reproduces issue #1885. with_timeout(Duration::from_secs(60), || { let (tx, mut rx) = mpsc::channel::<()>(1024); let rt ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
for _ in 1..=128 { handles.push(set.spawn_local(async move { tokio::task::spawn_local(async move {}).await.unwrap(); })); } rt.block_on(set.run_until(join_all(handles))); }); } #[test] fn local_tasks_are_polled_after_tick() { // This test depends on timi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
local .run_until(async { let task2 = task::spawn(async move { // Wait a bit time::sleep(Duration::from_millis(10)).await; let mut oneshots = Vec::with_capacity(EXPECTED); // Send values for _ in 0..EXPECTED { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
}) .await; } #[tokio::test] async fn acquire_mutex_in_drop() { use futures::future::pending; let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async move { let _ = rx2.await; unreachable!(); }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
481
535
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
#[tokio::test] async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = local.run_until(pending::<()>()).fuse() => unreachable!(), ret = async { local.spawn_local(ready(())).await.unwrap()}.fuse() => ret } } fn rt() -> Runtime { tokio::runtime::Builder::new_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/33f0a1fd2e5dd2c9f8bc3066fda38911828d26f5/tokio/tests/task_local_set.rs
521
535
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
with_timeout(Duration::from_secs(60), || { let (tx, mut rx) = mpsc::channel::<()>(1024); let rt = rt(); let local = LocalSet::new(); local.spawn_local(async move { while rx.recv().await.is_some() {} }); local.block_on(&rt, async { time::sleep(Duration::from_millis(1...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
0d9430b99cc699824cc8545afbb01e0a7c520428
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
#[tokio::test] async fn local_tasks_are_polled_after_tick() { // Reproduces issues #1899 and #1900 static RX1: AtomicUsize = AtomicUsize::new(0); static RX2: AtomicUsize = AtomicUsize::new(0); static EXPECTED: usize = 500; let (tx, mut rx) = mpsc::unbounded_channel(); let local = LocalSet::ne...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
0d9430b99cc699824cc8545afbb01e0a7c520428
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
while let Some(oneshot) = rx.recv().await { RX1.fetch_add(1, SeqCst); task::spawn_local(async move { oneshot.await.unwrap(); RX2.fetch_add(1, SeqCst); }); } task2.await.unwrap(); }) .await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
0d9430b99cc699824cc8545afbb01e0a7c520428
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
// Tick the loop local .run_until(async { task::yield_now().await; }) .await; // Drop the LocalSet drop(local); } #[tokio::test] async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = local.run_until(pending::<()>()).fuse()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
0d9430b99cc699824cc8545afbb01e0a7c520428
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/task_local_set.rs
481
506
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
}) .await .unwrap(); }) .await; } #[tokio::test(flavor = "multi_thread")] async fn localset_future_threadpool() { thread_local! { static ON_LOCAL_THREAD: Cell<bool> = Cell::new(false); } ON_LOCAL_THREAD.with(|cell| cell.set(true)); let local = LocalSet:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/task_local_set.rs
41
100
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
join2.await.unwrap() }); } #[test] fn drop_cancels_tasks() { use std::rc::Rc; // This test reproduces issue #1842 let rt = rt(); let rc1 = Rc::new(()); let rc2 = rc1.clone(); let (started_tx, started_rx) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async m...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
fn with_timeout(timeout: Duration, f: impl FnOnce() + Send + 'static) { use std::sync::mpsc::RecvTimeoutError; let (done_tx, done_rx) = std::sync::mpsc::channel(); let thread = std::thread::spawn(move || { f(); // Send a message on the channel so that the test thread can // determi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
fn drop_cancels_remote_tasks() { // This test reproduces issue #1885. with_timeout(Duration::from_secs(60), || { let (tx, mut rx) = mpsc::channel::<()>(1024); let rt = rt(); let local = LocalSet::new(); local.spawn_local(async move { while rx.recv().await.is_some() {} }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
} #[tokio::test] async fn local_tasks_are_polled_after_tick() { // Reproduces issues #1899 and #1900 static RX1: AtomicUsize = AtomicUsize::new(0); static RX2: AtomicUsize = AtomicUsize::new(0); static EXPECTED: usize = 500; let (tx, mut rx) = mpsc::unbounded_channel(); let local = LocalSet:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
assert_eq!(EXPECTED, rx2); }); while let Some(oneshot) = rx.recv().await { RX1.fetch_add(1, SeqCst); task::spawn_local(async move { oneshot.await.unwrap(); RX2.fetch_add(1, SeqCst); }); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
}); // Tick the loop local .run_until(async { task::yield_now().await; }) .await; // Drop the LocalSet drop(local); } #[tokio::test] async fn spawn_wakes_localset() { let local = LocalSet::new(); futures::select! { _ = local.run_until(pending::<()>(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/task_local_set.rs
481
508
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
join2.await.unwrap() }); } #[test] fn drop_cancels_tasks() { use std::rc::Rc; // This test reproduces issue #1842 let rt = rt(); let rc1 = Rc::new(()); let rc2 = rc1.clone(); let (started_tx, started_rx) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async m...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
fn with_timeout(timeout: Duration, f: impl FnOnce() + Send + 'static) { use std::sync::mpsc::RecvTimeoutError; let (done_tx, done_rx) = std::sync::mpsc::channel(); let thread = std::thread::spawn(move || { f(); // Send a message on the channel so that the test thread can // determi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use tokio::runtime::{self, Runtime}; use tokio::sync::{mpsc, oneshot}; use tokio::task::{self, LocalSet}; use tokio::time; use std::cell::Cell; use std::sync::atomic::Ordering::{self, SeqCst}; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::time::Duratio...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
} #[tokio::test(flavor = "multi_thread")] async fn localset_future_threadpool() { thread_local! { static ON_LOCAL_THREAD: Cell<bool> = Cell::new(false); } ON_LOCAL_THREAD.with(|cell| cell.set(true)); let local = LocalSet::new(); local.spawn_local(async move { assert!(ON_LOCAL_THRE...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
41
100
tokio-rs/tokio:tokio/tests/task_local_set.rs:3
static RAN3: AtomicBool = AtomicBool::new(false); let local = LocalSet::new(); local.spawn_local(async move { task::spawn_local(async { task::yield_now().await; RAN3.store(true, Ordering::SeqCst); }); task::yield_now().await; RAN1.store(true, Ordering::Se...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
81
140
tokio-rs/tokio:tokio/tests/task_local_set.rs:4
}) .await; } #[test] // This will panic, since the thread that calls `block_on` cannot use // in-place blocking inside of `block_on`. #[should_panic] fn local_threadpool_blocking_in_place() { thread_local! { static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cel...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
assert!(ON_RT_THREAD.with(|cell| cell.get())); let join = task::spawn_local(async move { assert!(ON_RT_THREAD.with(|cell| cell.get())); task::spawn_blocking(|| { assert!( !ON_RT_THREAD.with(|cell| cell.get()), ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
}) .await; } #[tokio::test(flavor = "multi_thread")] async fn nested_spawn_is_local() { thread_local! { static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); LocalSet::new() .run_until(async { assert!(ON_RT_THREAD.with(|cel...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
201
260
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
fn join_local_future_elsewhere() { thread_local! { static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); let rt = runtime::Runtime::new().unwrap(); let local = LocalSet::new(); local.block_on(&rt, async move { let (tx, rx) = oneshot::ch...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
fn drop_cancels_tasks() { use std::rc::Rc; // This test reproduces issue #1842 let rt = rt(); let rc1 = Rc::new(()); let rc2 = rc1.clone(); let (started_tx, started_rx) = oneshot::channel(); let local = LocalSet::new(); local.spawn_local(async move { // Move this in le...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
f(); // Send a message on the channel so that the test thread can // determine if we have entered an infinite loop: done_tx.send(()).unwrap(); }); // Since the failure mode of this test is an infinite loop, rather than // something we can easily make assertions about, we'll run it ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
let rt = rt(); let local = LocalSet::new(); local.spawn_local(async move { while rx.recv().await.is_some() {} }); local.block_on(&rt, async { time::sleep(Duration::from_millis(1)).await; }); drop(tx); // This enters an infinite loop if the remote notified t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
static RX1: AtomicUsize = AtomicUsize::new(0); static RX2: AtomicUsize = AtomicUsize::new(0); static EXPECTED: usize = 500; let (tx, mut rx) = mpsc::unbounded_channel(); let local = LocalSet::new(); local .run_until(async { let task2 = task::spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
task::spawn_local(async move { oneshot.await.unwrap(); RX2.fetch_add(1, SeqCst); }); } task2.await.unwrap(); }) .await; } #[tokio::test] async fn acquire_mutex_in_drop() { use futures::future::pending; let (tx1, r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local_set.rs
441
494