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.rs:3
if !err.is_cancelled() { if let Ok(panic) = err.try_into_panic() { std::panic::resume_unwind(panic); } else { panic!(); } } } #[tokio::test] async fn task_local_available_on_completion_drop() { tokio::task_local! { static KEY: u32; } struct MyFut...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/task_local.rs
81
118
tokio-rs/tokio:tokio/tests/task_local.rs:1
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::sync::oneshot; #[tokio::test(flavor = "multi_thread")] async fn local() { tokio::task_local! { static REQ_ID: u32; pub stati...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/task_local.rs
1
60
tokio-rs/tokio:tokio/tests/task_local.rs:1
#![cfg(feature = "full")] use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::sync::oneshot; #[tokio::test(flavor = "multi_thread")] async fn local() { tokio::task_local! { static REQ_ID: u32; pub static FOO: bool; } let j1 = tokio::spawn(REQ_ID.scope(1, ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local.rs
MIT
e6020c0fed28128fce85d69352b540ddc1bbaf69
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6020c0fed28128fce85d69352b540ddc1bbaf69/tokio/tests/task_local.rs
1
60
tokio-rs/tokio:tokio/tests/task_local.rs:1
#![cfg(feature = "full")] tokio::task_local! { static REQ_ID: u32; pub static FOO: bool; } #[tokio::test(flavor = "multi_thread")] async fn local() { let j1 = tokio::spawn(REQ_ID.scope(1, async move { assert_eq!(REQ_ID.get(), 1); assert_eq!(REQ_ID.get(), 1); })); let j2 = tokio::s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local.rs
MIT
2747043f6f7e0870cc5aa72c146dfae9543c5ba8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/tests/task_local.rs
1
33
tokio-rs/tokio:tokio/tests/task_local.rs:1
tokio::task_local! { static REQ_ID: u32; pub static FOO: bool; } #[tokio::test(flavor = "multi_thread")] async fn local() { let j1 = tokio::spawn(REQ_ID.scope(1, async move { assert_eq!(REQ_ID.get(), 1); assert_eq!(REQ_ID.get(), 1); })); let j2 = tokio::spawn(REQ_ID.scope(2, async ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/task_local.rs
1
31
tokio-rs/tokio:tokio/tests/task_local.rs:1
tokio::task_local! { static REQ_ID: u32; pub static FOO: bool; } #[tokio::test(threaded_scheduler)] async fn local() { let j1 = tokio::spawn(REQ_ID.scope(1, async move { assert_eq!(REQ_ID.get(), 1); assert_eq!(REQ_ID.get(), 1); })); let j2 = tokio::spawn(REQ_ID.scope(2, async move ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/task_local.rs
1
31
tokio-rs/tokio:tokio/tests/task_local.rs:1
tokio::task_local! { static REQ_ID: u32; pub static FOO: bool; } #[tokio::test(threaded_scheduler)] async fn local() { let j1 = tokio::spawn(REQ_ID.scope(1, async move { assert_eq!(REQ_ID.get(), 1); assert_eq!(REQ_ID.get(), 1); })); let j2 = tokio::spawn(REQ_ID.scope(2, async move ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local.rs
MIT
619d730d610bbfd0a13285178d6bf3d89a29d6a3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/619d730d610bbfd0a13285178d6bf3d89a29d6a3/tokio/tests/task_local.rs
1
31
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
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
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())); }) .await .unwrap(); }) .await; } #[cfg(not(target_os = "wasi"))...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
41
100
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
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
81
140
tokio-rs/tokio:tokio/tests/task_local_set.rs:4
static ON_RT_THREAD: Cell<bool> = const { 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(|c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
struct BlockInPlaceOnDrop; impl Future for BlockInPlaceOnDrop { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> { Poll::Pending } } impl Drop for BlockInPlaceOnDrop { fn drop(&mut self) { tokio::task::block...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
task::block_in_place(|| {}); assert!(ON_RT_THREAD.with(|cell| cell.get())); }); complete(join).await; }); } #[tokio::test(flavor = "multi_thread")] #[should_panic = "can call blocking only when running on the multi-threaded runtime"] async fn block_in_pla...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
201
260
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
#[should_panic = "can call blocking only when running on the multi-threaded runtime"] async fn block_in_place_in_run_until_ct() { let local_set = LocalSet::new(); local_set .run_until(async { tokio::task::block_in_place(|| {}); }) .await; } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
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(|| { assert!( !ON_RT...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
.collect::<Vec<_>>(); for joined in future::join_all(handles).await { joined.unwrap(); } }) .await; } #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn nested_spawn_is_local() { thread_local! { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
}) .await; } #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[test] fn join_local_future_elsewhere() { thread_local! { static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) }; } ON_RT_THREAD.with(|cell| cell.set(true)); let rt = runtime::Runtime::new().unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
// Tests for <https://github.com/tokio-rs/tokio/issues/4973> #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn localset_in_thread_local() { thread_local! { static LOCAL_SET: LocalSet = LocalSet::new(); } // holds runtime thread until en...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
local.block_on(&rt, async { started_rx.await.unwrap(); }); 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 i...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
), // Did the test thread panic? We'll find out for sure when we `join` // with it. Err(RecvTimeoutError::Disconnected) => {} // Test completed successfully! Ok(()) => {} } thread.join().expect("test thread should not panic!") } #[cfg_attr( target_os = "wasi", i...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
)] #[test] fn local_tasks_wake_join_all() { // This test reproduces issue #2460. with_timeout(Duration::from_secs(60), || { use futures::future::join_all; use tokio::task::LocalSet; let rt = rt(); let set = LocalSet::new(); let mut handles = Vec::new(); for _ in...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
#[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
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:16
if rx1 == EXPECTED && rx2 == EXPECTED { break; } } }); while let Some(oneshot) = rx.recv().await { RX1.fetch_add(1, SeqCst); task::spawn_local(async move { oneshot.await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
601
660
tokio-rs/tokio:tokio/tests/task_local_set.rs:17
// Spawn a task that will never notify local.spawn_local(async move { pending::<()>().await; tx1.send(()).unwrap(); }); // Tick the loop local .run_until(async { task::yield_now().await; }) .await; // Drop the LocalSet drop(local); } #[tokio...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
641
700
tokio-rs/tokio:tokio/tests/task_local_set.rs:18
tx.send(()).expect("failed to send"); }); assert_eq!(rx.await, Ok(())); }) .await; } #[test] fn store_local_set_in_thread_local_with_runtime() { use tokio::runtime::Runtime; thread_local! { static CURRENT: RtAndLocalSet = RtAndLocalSet::new(); } struct ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
681
740
tokio-rs/tokio:tokio/tests/task_local_set.rs:19
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 task panicked and the LocalSet ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
721
780
tokio-rs/tokio:tokio/tests/task_local_set.rs:20
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 { loop { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/task_local_set.rs
761
808
tokio-rs/tokio:tokio/tests/task_local_set.rs:4
static ON_RT_THREAD: Cell<bool> = const { 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(|c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
struct BlockInPlaceOnDrop; impl Future for BlockInPlaceOnDrop { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> { Poll::Pending } } impl Drop for BlockInPlaceOnDrop { fn drop(&mut self) { tokio::task::block...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:4
static ON_RT_THREAD: Cell<bool> = const { 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(|c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) }; } ON_RT_THREAD.with(|cell| cell.set(true)); let rt = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); LocalSet::new().block_on(&rt, async { assert!(ON_RT_THREAD.with(|cell| cell.get())...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
.await .unwrap(); assert!(ON_RT_THREAD.with(|cell| cell.get())); }); join.await.unwrap(); }) .await; } #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn all_spawns_are_local() { us...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
201
260
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
static ON_RT_THREAD: Cell<bool> = const { 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
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/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 { assert!( ON_RT_THREAD.with(|cell| cell.get()), "local task must run on...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
std::thread::spawn(move || { LOCAL_SET.with(|local_set| { handle.block_on(local_set.run_until(async move { let _ = rx.await; })) }); }); } #[test] fn drop_cancels_tasks() { use std::rc::Rc; // This test reproduces issue #1842 let rt = rt(); l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
/// /// This is intended for running tests whose failure mode is a hang or infinite /// loop that cannot be detected otherwise. 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 = st...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
target_os = "wasi", ignore = "`unwrap()` in `with_timeout()` panics on Wasi" )] #[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 = rt(); let local = LocalSet...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
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))); }); } #[cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery #[test] fn...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
let local = LocalSet::new(); 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 ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
RX2.fetch_add(1, SeqCst); }); } task2.await.unwrap(); }) .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::ne...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
// 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() => ret } } /// Checks th...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:16
static CURRENT: RtAndLocalSet = RtAndLocalSet::new(); } struct RtAndLocalSet { rt: Runtime, local: LocalSet, } impl RtAndLocalSet { fn new() -> RtAndLocalSet { RtAndLocalSet { rt: tokio::runtime::Builder::new_current_thread() .ena...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
601
660
tokio-rs/tokio:tokio/tests/task_local_set.rs:17
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(UnhandledPanic::ShutdownRuntime) .run_u...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
641
700
tokio-rs/tokio:tokio/tests/task_local_set.rs:18
} }); // Poll once assert!(!spawned.poll().is_ready()); } spawned_n }); let mut run_until_n = 0; { let mut run_until = tokio_test::task::s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/task_local_set.rs
681
716
tokio-rs/tokio:tokio/tests/task_local_set.rs:1
#![allow(unknown_lints, unexpected_cfgs)] #![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; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
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())); }) .await .unwrap(); }) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
41
100
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() { s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/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> = const { 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 { asse...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
thread_local! { static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) }; } ON_RT_THREAD.with(|cell| cell.set(true)); let rt = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); LocalSet::new().block_on(&rt, async { assert!(ON_RT_THREAD...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
}) .await .unwrap(); assert!(ON_RT_THREAD.with(|cell| cell.get())); }); join.await.unwrap(); }) .await; } #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn all_spawns_a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
201
260
tokio-rs/tokio:tokio/tests/task_local_set.rs:7
thread_local! { static ON_RT_THREAD: Cell<bool> = const { 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...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:8
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::channel(); 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
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:9
std::thread::spawn(move || { LOCAL_SET.with(|local_set| { handle.block_on(local_set.run_until(async move { let _ = rx.await; })) }); }); } #[test] fn drop_cancels_tasks() { use std::rc::Rc; // This test reproduces issue #1842 let rt = rt(); l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
321
380
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
/// 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 otherwise. fn with_timeout(timeout: Duration, f: impl FnOnce() + Send + 'static) { use std::sync::mpsc::RecvTimeoutError; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
#[cfg_attr( target_os = "wasi", ignore = "`unwrap()` in `with_timeout()` panics on Wasi" )] #[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 = rt(); let ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
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; let mut oneshots = Vec::with_capacity(EXPECT...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
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, rx1) = oneshot::channel(); let (tx2, rx2) = ones...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/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() => ret } } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:16
thread_local! { static CURRENT: RtAndLocalSet = RtAndLocalSet::new(); } struct RtAndLocalSet { rt: Runtime, local: LocalSet, } impl RtAndLocalSet { fn new() -> RtAndLocalSet { RtAndLocalSet { rt: tokio::runtime::Builder::new_current_thread() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
601
660
tokio-rs/tokio:tokio/tests/task_local_set.rs:17
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
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
641
700
tokio-rs/tokio:tokio/tests/task_local_set.rs:18
tokio::task::consume_budget().await; } }); // Poll once assert!(!spawned.poll().is_ready()); } spawned_n }); let mut run_until_n = 0; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/task_local_set.rs
681
717
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
/// 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 otherwise. fn with_timeout(timeout: Duration, f: impl FnOnce() + Send + 'static) { use std::sync::mpsc::RecvTimeoutError; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
#[cfg_attr( target_os = "wasi", ignore = "`unwrap()` in `with_timeout()` panics on Wasi" )] #[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 = rt(); let ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
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))); }); } #[cfg(not(target_os = "wasi"))] // Wasi do...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
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; let mut oneshots = Vec::with_capacity(EXPECT...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/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
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/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
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:17
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
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_local_set.rs
641
700
tokio-rs/tokio:tokio/tests/task_local_set.rs:18
spawned_n += 1; tokio::task::consume_budget().await; } }); // Poll once assert!(!spawned.poll().is_ready()); } spawned_n }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/task_local_set.rs
681
718
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
/// /// This is intended for running tests whose failure mode is a hang or infinite /// loop that cannot be detected otherwise. 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 = st...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/task_local_set.rs
361
420
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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
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())); }) .await .unwrap(); }) .await; } #[cfg(not(target_os = "wasi"))...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/tests/task_local_set.rs
41
100
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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); let rt = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); LocalSet::new().block_on(&rt, async { assert!(ON_RT_THREAD.with(|cell| cell.get())); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
.await .unwrap(); assert!(ON_RT_THREAD.with(|cell| cell.get())); }); join.await.unwrap(); }) .await; } #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn all_spawns_are_local() { us...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/tests/task_local_set.rs
201
260
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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/tests/task_local_set.rs
241
300
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
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, rx1) = oneshot::channel(); let (tx2, rx2) = ones...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/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() => ret } } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:16
self.local .run_until(async move { tokio::task::spawn_local(async {}); }) .await } fn method(&self) { self.rt.block_on(self.inner_method()); } } CURRENT.with(|f| { f.method(); }); } #[cfg(tokio...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/task_local_set.rs
601
660
tokio-rs/tokio:tokio/tests/task_local_set.rs:17
// consumed budget, the `run_until` future has less budget than a "spawned" // task. // // "Budget" is a fuzzy metric as the Tokio runtime is able to change values // internally. This is why the test uses indirection to test this. #[tokio::test] async fn run_until_does_not_get_own_budget() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/task_local_set.rs
641
696
tokio-rs/tokio:tokio/tests/task_local_set.rs:18
let spawned_n = spawned.await.unwrap(); assert_ne!(spawned_n, 0); assert_ne!(run_until_n, 0); assert!(spawned_n > run_until_n); }) .await } } fn rt() -> runtime::Runtime { tokio::runtime::Builder::new_current_thread() .enable_all()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/task_local_set.rs
681
696
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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
1
60
tokio-rs/tokio:tokio/tests/task_local_set.rs:2
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())); }) .await .unwrap(); }) .await; } #[cfg(not(tokio_wasi))] // Was...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
41
100
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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
121
180
tokio-rs/tokio:tokio/tests/task_local_set.rs:5
static ON_RT_THREAD: Cell<bool> = Cell::new(false); } ON_RT_THREAD.with(|cell| cell.set(true)); let rt = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); LocalSet::new().block_on(&rt, async { assert!(ON_RT_THREAD.with(|cell| cell.get())); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
161
220
tokio-rs/tokio:tokio/tests/task_local_set.rs:6
.await .unwrap(); assert!(ON_RT_THREAD.with(|cell| cell.get())); }); join.await.unwrap(); }) .await; } #[cfg(not(tokio_wasi))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn all_spawns_are_local() { use future...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
201
260
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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/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 { assert!( ON_RT_THREAD.with(|cell| cell.get()), "local task must run on...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
281
340
tokio-rs/tokio:tokio/tests/task_local_set.rs:10
/// /// This is intended for running tests whose failure mode is a hang or infinite /// loop that cannot be detected otherwise. 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 = st...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
361
420
tokio-rs/tokio:tokio/tests/task_local_set.rs:11
#[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_secs(60), || { let (tx, mut rx) = mpsc::channel::<()>(1024); let rt = rt(); let local = LocalSet::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
401
460
tokio-rs/tokio:tokio/tests/task_local_set.rs:12
tokio::task::spawn_local(async move {}).await.unwrap(); })); } rt.block_on(set.run_until(join_all(handles))); }); } #[cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery #[test] fn local_tasks_are_polled_after_tick() { // This test depends on timing, so we run it up to fiv...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
441
500
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
481
540
tokio-rs/tokio:tokio/tests/task_local_set.rs:14
} task2.await.unwrap(); }) .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 _ = r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
521
580
tokio-rs/tokio:tokio/tests/task_local_set.rs:15
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() => ret } } #[test] fn store_local_set_in_thread_l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
561
620
tokio-rs/tokio:tokio/tests/task_local_set.rs:16
}) .await } 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] #...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
601
660
tokio-rs/tokio:tokio/tests/task_local_set.rs:17
// "Budget" is a fuzzy metric as the Tokio runtime is able to change values // internally. This is why the test uses indirection to test this. #[tokio::test] async fn run_until_does_not_get_own_budget() { // Consume some budget tokio::task::consume_budget().await; LocalSet::new() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/task_local_set.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
641
693
tokio-rs/tokio:tokio/tests/task_local_set.rs:18
assert_ne!(run_until_n, 0); assert!(spawned_n > run_until_n); }) .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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/task_local_set.rs
681
693
tokio-rs/tokio:tokio/tests/task_local_set.rs:13
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
b7812c85ca2d051d47cec023b880cbf8cdcbc313
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/tests/task_local_set.rs
481
540