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/rt_threaded.rs:21 | rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});
std::thread::yield_now();
}
}
flag.store(false, Relaxed);
let w = Arc::downgrade(&interval);
drop(interval);
while w.strong_count() > 0 {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:22 | }
if n == 3 {
break;
}
if Arc::strong_count(&interval) <= 5_000 {
let counter = counter.clone();
let interval = interval.clone();
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Rel... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:23 | assert_ne!(rt1.handle().name().unwrap(), rt2.handle().name().unwrap());
}
fn rt() -> runtime::Runtime {
runtime::Runtime::new().unwrap()
}
#[cfg(tokio_unstable)]
mod unstable {
use super::*;
#[test]
fn test_disable_lifo_slot() {
use std::sync::mpsc::{channel, RecvTimeoutError};
let r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:24 | rt.block_on(async {
tokio::spawn(async {
// Spawn another task and block the thread until completion. If the LIFO slot
// is used then the test doesn't complete.
futures::executor::block_on(tokio::spawn(async {})).unwrap();
})
.await
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 921 | 953 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:17 | });
})
})
.await
.unwrap()
});
}
}
#[test]
fn yield_now_in_block_in_place() {
let rt = runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async move {
for i in 0..(BUDGET + 1) {
let mut guard = lock.lock().await;
*guard = i;
}
});
})
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | // task, so that it is placed in the worker's LIFO slot.
let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let rt = runtime::Builder::new_multi_thread()
// Make sure there are enough workers that one can be parked running the
// I/O driver and another can be parked running the timer ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | // blocking forever.
tokio::spawn(async move {
println!("[blocker] sending wakeup");
notify_tx.send(()).unwrap();
println!("[blocker] blocking the worker thread...");
// Block the worker thread indefinitely by waiting for a message on
// a blocking ch... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:21 | #[test]
/// Deferred tasks should be woken before starting the [`tokio::task::block_in_place`]
// https://github.com/tokio-rs/tokio/issues/7877
fn wake_deferred_tasks_before_block_in_place() {
let (tx1, rx1) = oneshot::channel::<()>();
let (tx2, rx2) = oneshot::channel::<()>();
let deferred_task = tokio_te... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:22 | // signal the `block_in_place` to shutdown
tx1.send(()).unwrap();
rt.block_on(jh).unwrap();
assert!(is_woken);
}
// Testing the tuning logic is tricky as it is inherently timing based, and more
// of a heuristic than an exact behavior. This test checks that the interval
// changes over time based on load... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:23 | let flag = flag.clone();
let counter = counter.clone();
rt.spawn(async move { iter(flag, counter, true) });
}
// Now, hammer the injection queue until the interval drops.
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
if curr <= 8 {
n += 1;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:24 | while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(AtomicBool::new(true));
// Set it high, we know it shouldn't ever really be this high
let counter = Arc::new(AtomicUsize::new(10_000));
let interval... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:25 | }
std::thread::yield_now();
}
flag.store(false, Relaxed);
}
#[test]
fn default_runtime_name_should_be_none() {
let rt1 = runtime::Builder::new_multi_thread().build().unwrap();
assert!(rt1.handle().name().is_none());
}
#[test]
fn different_runtime_names() {
let rt1 = runtime::Builder::ne... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:26 | let rt = runtime::Builder::new_multi_thread()
.disable_lifo_slot()
.worker_threads(2)
.build()
.unwrap();
// Spawn a background thread to poke the runtime periodically.
//
// This is necessary because we may end up triggering the issue in:
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 1,001 | 1,059 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:27 | #[test]
fn runtime_id_is_same() {
let rt = rt();
let handle1 = rt.handle();
let handle2 = rt.handle();
assert_eq!(handle1.id(), handle2.id());
}
#[test]
fn runtime_ids_different() {
let rt1 = rt();
let rt2 = rt();
assert_ne!(rt1.handle().id(), ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7db9bc41f18dffb6953f762a5f8e2f4ddb54d80d/tokio/tests/rt_threaded.rs | 1,041 | 1,059 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async move {
for i in 0..(BUDGET + 1) {
let mut guard = lock.lock().await;
*guard = i;
}
});
})
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | // task, so that it is placed in the worker's LIFO slot.
let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let rt = runtime::Builder::new_multi_thread()
// Make sure there are enough workers that one can be parked running the
// I/O driver and another can be parked running the timer ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | // Using a channel rather than e.g. `loop {}` allows us to terminate
// the task cleanly when the test finishes.
let _ = block_thread_rx.recv();
println!("[blocker] done");
});
println!("[main] blocker task spawned");
// Wait for the victim task to join. If ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:21 | .unwrap();
let jh = {
let deferred_task = Arc::clone(&deffered_task);
rt.spawn(async move {
{
let mut lock = deferred_task.lock().unwrap();
assert_pending!(lock.poll());
}
tokio::task::block_in_place(|| {
// signal ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:22 | #[test]
#[cfg(not(tokio_no_tuning_tests))]
fn test_tuning() {
use std::sync::atomic::AtomicBool;
use std::time::Duration;
let rt = runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
fn iter(flag: Arc<AtomicBool>, counter: Arc<AtomicUsize>, stall: bool) ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:23 | n = 0;
}
// Make sure we get a few good rounds. Jitter in the tuning could result
// in one "good" value without being representative of reaching a good
// state.
if n == 3 {
break;
}
if Arc::strong_count(&interval) < 5_000 {
let counter ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:24 | let counter = counter.clone();
rt.spawn(async move { iter(flag, counter, false) });
}
// Now, hammer the injection queue until the interval reaches the expected range.
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
if curr <= 1_000 && curr > 32 {
n += 1;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:25 | }
#[test]
fn different_runtime_names() {
let rt1 = runtime::Builder::new_multi_thread()
.name("test-runtime-1")
.build()
.unwrap();
let rt2 = runtime::Builder::new_multi_thread()
.name("test-runtime-2")
.build()
.unwrap();
assert_ne!(rt1.handle().name().unwr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:26 | // the task. However, the steal will fail if the task is in the LIFO
// slot, because the LIFO slot cannot be stolen.
//
// Note that this only happens rarely. Most of the time, this thread is
// not necessary.
let (kill_bg_thread, recv) = channel::<()>();
let handle = rt... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 6c03e03898d71eca976ee1ad8481cf112ae722ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c03e03898d71eca976ee1ad8481cf112ae722ba/tokio/tests/rt_threaded.rs | 1,001 | 1,046 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:22 | }
if n == 3 {
break;
}
if Arc::strong_count(&interval) <= 5_000 {
let counter = counter.clone();
let interval = interval.clone();
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Rel... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 0d6c7af3e43457350bdc03a6dbcafa276fab7352 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d6c7af3e43457350bdc03a6dbcafa276fab7352/tokio/tests/rt_threaded.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:23 | // Spawn a background thread to poke the runtime periodically.
//
// This is necessary because we may end up triggering the issue in:
// <https://github.com/tokio-rs/tokio/issues/4730>
//
// Spawning a task will wake up the second worker, which will then steal
// the task... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 0d6c7af3e43457350bdc03a6dbcafa276fab7352 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d6c7af3e43457350bdc03a6dbcafa276fab7352/tokio/tests/rt_threaded.rs | 881 | 932 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:24 | assert_eq!(handle1.id(), handle2.id());
}
#[test]
fn runtime_ids_different() {
let rt1 = rt();
let rt2 = rt();
assert_ne!(rt1.handle().id(), rt2.handle().id());
}
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 0d6c7af3e43457350bdc03a6dbcafa276fab7352 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d6c7af3e43457350bdc03a6dbcafa276fab7352/tokio/tests/rt_threaded.rs | 921 | 932 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
// Too slow on miri.
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::future::{poll_fn, F... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | addbfb9204be25a8621feb3f20b44a7c1f00edbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/addbfb9204be25a8621feb3f20b44a7c1f00edbd/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:17 | });
})
})
.await
.unwrap()
});
}
}
#[test]
fn yield_now_in_block_in_place() {
let rt = runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | addbfb9204be25a8621feb3f20b44a7c1f00edbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/addbfb9204be25a8621feb3f20b44a7c1f00edbd/tokio/tests/rt_threaded.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async move {
for i in 0..(BUDGET + 1) {
let mut guard = lock.lock().await;
*guard = i;
}
});
})
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | addbfb9204be25a8621feb3f20b44a7c1f00edbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/addbfb9204be25a8621feb3f20b44a7c1f00edbd/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | let flag = Arc::new(AtomicBool::new(true));
let counter = Arc::new(AtomicUsize::new(61));
let interval = Arc::new(AtomicUsize::new(61));
{
let flag = flag.clone();
let counter = counter.clone();
rt.spawn(async move { iter(flag, counter, true) });
}
// Now, hammer the inject... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | addbfb9204be25a8621feb3f20b44a7c1f00edbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/addbfb9204be25a8621feb3f20b44a7c1f00edbd/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | }
flag.store(false, Relaxed);
let w = Arc::downgrade(&interval);
drop(interval);
while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(AtomicBool::new(true));
// Set it high, we know it shoul... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | addbfb9204be25a8621feb3f20b44a7c1f00edbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/addbfb9204be25a8621feb3f20b44a7c1f00edbd/tokio/tests/rt_threaded.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:21 | let interval = interval.clone();
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});
}
std::thread::yield_now();
}
flag.store(false, Relaxed);
}
fn rt() -> runtime::Runtime {
runtime::Runtim... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | addbfb9204be25a8621feb3f20b44a7c1f00edbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/addbfb9204be25a8621feb3f20b44a7c1f00edbd/tokio/tests/rt_threaded.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:22 | //
// Note that this only happens rarely. Most of the time, this thread is
// not necessary.
let (kill_bg_thread, recv) = channel::<()>();
let handle = rt.handle().clone();
let bg_thread = std::thread::spawn(move || {
let one_sec = std::time::Duration::from_secs(1);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | addbfb9204be25a8621feb3f20b44a7c1f00edbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/addbfb9204be25a8621feb3f20b44a7c1f00edbd/tokio/tests/rt_threaded.rs | 841 | 884 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:16 | tokio::task::block_in_place(|| {});
}
#[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio::task::block_in_place(|| {});
}
#[should_panic]
#[tokio::main(flavor = "current_thread")]
#[test]
async fn test_block_in_place3() {
tokio::task::block_in_place(|| {});
}
#[tokio::main]
#[test... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:17 | });
})
})
.await
.unwrap()
});
}
}
// Testing the tuning logic is tricky as it is inherently timing based, and more
// of a heuristic than an exact behavior. This test checks that the interval
// changes over time based on load factors. There are no asser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | {
let flag = flag.clone();
let counter = counter.clone();
rt.spawn(async move { iter(flag, counter, true) });
}
// Now, hammer the injection queue until the interval drops.
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
if curr <= 8 {
n += ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | drop(interval);
while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(AtomicBool::new(true));
// Set it high, we know it shouldn't ever really be this high
let counter = Arc::new(AtomicUsize::new(10_00... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | });
}
std::thread::yield_now();
}
flag.store(false, Relaxed);
}
fn rt() -> runtime::Runtime {
runtime::Runtime::new().unwrap()
}
#[cfg(tokio_unstable)]
mod unstable {
use super::*;
#[test]
fn test_disable_lifo_slot() {
use std::sync::mpsc::{channel, RecvTimeoutError}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:21 | let bg_thread = std::thread::spawn(move || {
let one_sec = std::time::Duration::from_secs(1);
while recv.recv_timeout(one_sec) == Err(RecvTimeoutError::Timeout) {
handle.spawn(async {});
}
});
rt.block_on(async {
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded.rs | 801 | 839 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
// Too slow on miri.
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:4 | next_tx.send(v).await.unwrap();
}
});
chain_rx = next_rx;
}
// This final task cycles if needed
let (final_tx, final_rx) = tokio::sync::mpsc::channel(10);
let cycle_tx = start_tx.clone();
let mut rem = CYCL... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:5 | }
}
}
#[test]
fn lifo_slot_budget() {
async fn my_fn() {
spawn_another();
}
fn spawn_another() {
tokio::spawn(my_fn());
}
let rt = runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(1)
.build()
.unwrap();
let (send, recv) = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:6 | // Use spawner
rt.spawn(client_server(tx));
assert_ok!(rx.recv());
assert_ok!(rx.recv());
drop(rt);
assert_err!(rx.try_recv());
}
async fn client_server(tx: mpsc::Sender<()>) {
let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await);
// Get the assigned address
let addr = ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:7 | struct Never(Arc<AtomicUsize>);
impl Future for Never {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Pending
}
}
impl Drop for Never {
fn drop(&mut self) {
self.0.fetc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | // Assert that all threads shutdown
let b = num_dec.load(Relaxed);
assert_eq!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
assert_eq!(c, 1);
}
}
#[test]
fn start_stop_callbacks_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:9 | assert!(after_start.load(Ordering::Relaxed) > 0);
assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
// too slow on miri
#[cfg_attr(miri, ignore)]
fn blocking() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:10 | }
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
block.wait();
}
}
#[test]
fn multi_threadpool() {
use tokio::sync::oneshot;
let rt1 = rt();
let rt2 = rt();
let (tx, rx) = oneshot::channel();
let (done_tx, done_rx) = mpsc::channel();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:11 | fn coop_and_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread()
// Setting max threads to 1 prevents another thread from claiming the
// runtime worker yielded as part of `block_in_place` and guarantees the
// same thread will reclaim the worker at the end of the
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:12 | })
.await
})
.await
.unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:13 | .unwrap();
}
#[test]
#[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread()
.max_blocking_threads(0)
.build()
.unwrap();
}
/// Regression test for #6445.
///
/// After #6445, setting `global_queue_interval` to 1 is now technically vali... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:14 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn hang_on_shutdown() {
let (sync_tx, sync_rx) = std::sync::mpsc::channel::<()>();
tokio::spawn(async move {
tokio::task::block_in_place(|| sync_rx.recv().ok());
});
tokio::spawn(async {
tokio::time::sleep(std::time::Dura... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:15 | impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
let me = Pin::into_inner(self);
let mut lock = me.shared.lock().unwrap();
if me.put_waker {
lock.waker = Some(cx.waker().clone());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:16 | async fn test_block_in_place1() {
tokio::task::block_in_place(|| {});
}
#[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio::task::block_in_place(|| {});
}
#[should_panic]
#[tokio::main(flavor = "current_thread")]
#[test]
async fn test_block_in_place3() {
tokio::task::block_in_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:17 | tokio::task::block_in_place(|| {});
});
})
})
.await
.unwrap()
});
}
}
// Testing the tuning logic is tricky as it is inherently timing based, and more
// of a heuristic than an exact behavior. This test checks that the interval
// cha... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | {
let flag = flag.clone();
let counter = counter.clone();
rt.spawn(async move { iter(flag, counter, true) });
}
// Now, hammer the injection queue until the interval drops.
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
if curr <= 8 {
n += ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | let w = Arc::downgrade(&interval);
drop(interval);
while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(AtomicBool::new(true));
// Set it high, we know it shouldn't ever really be this high
let co... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | interval.store(prev, Relaxed);
});
}
std::thread::yield_now();
}
flag.store(false, Relaxed);
}
fn rt() -> runtime::Runtime {
runtime::Runtime::new().unwrap()
}
#[cfg(tokio_unstable)]
mod unstable {
use super::*;
#[test]
fn test_disable_lifo_slot() {
use s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:21 | let handle = rt.handle().clone();
let bg_thread = std::thread::spawn(move || {
let one_sec = std::time::Duration::from_secs(1);
while recv.recv_timeout(one_sec) == Err(RecvTimeoutError::Timeout) {
handle.spawn(async {});
}
});
rt.block_on(asyn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/rt_threaded.rs | 801 | 840 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:5 | }
}
}
#[test]
fn lifo_slot_budget() {
async fn my_fn() {
spawn_another();
}
fn spawn_another() {
tokio::spawn(my_fn());
}
let rt = runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(1)
.build()
.unwrap();
let (send, recv) = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_threaded.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::future::{... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:5 | }
}
#[test]
fn lifo_slot_budget() {
async fn my_fn() {
spawn_another();
}
fn spawn_another() {
tokio::spawn(my_fn());
}
let rt = runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(1)
.build()
.unwrap();
let (send, recv) = onesho... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:6 | assert_ok!(rx.recv());
assert_ok!(rx.recv());
drop(rt);
assert_err!(rx.try_recv());
}
async fn client_server(tx: mpsc::Sender<()>) {
let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await);
// Get the assigned address
let addr = assert_ok!(server.local_addr());
// Spawn the serve... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:7 | impl Future for Never {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Pending
}
}
impl Drop for Never {
fn drop(&mut self) {
self.0.fetch_add(1, Relaxed);
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | assert_eq!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
assert_eq!(c, 1);
}
}
#[test]
fn start_stop_callbacks_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
let after_start = Arc::new(AtomicUsize::new(0));
let before_stop = Arc::new(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:9 | }
#[test]
fn blocking() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new(AtomicUsize::new(0));
// there are four workers in the pool
// so, if we run 4 blocking tas... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:10 | rx.recv().unwrap();
// Wait for the pool to shutdown
block.wait();
}
}
#[test]
fn multi_threadpool() {
use tokio::sync::oneshot;
let rt1 = rt();
let rt2 = rt();
let (tx, rx) = oneshot::channel();
let (done_tx, done_rx) = mpsc::channel();
rt2.spawn(async move {
rx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:11 | // same thread will reclaim the worker at the end of the
// `block_in_place` call.
.max_blocking_threads(1)
.build()
.unwrap();
rt.block_on(async move {
let (tx, mut rx) = tokio::sync::mpsc::channel(1024);
// Fill the channel
for _ in 0..1024 {
t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:12 | .unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place then enter a new runtime
tokio::tas... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:13 | #[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread()
.max_blocking_threads(0)
.build()
.unwrap();
}
/// Regression test for #6445.
///
/// After #6445, setting `global_queue_interval` to 1 is now technically valid.
/// This test confi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:15 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
let me = Pin::into_inner(self);
let mut lock = me.shared.lock().unwrap();
if me.put_waker {
lock.waker = Some(cx.waker().clone());
}
Poll::Pending
}
}
impl Drop ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:16 | #[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio::task::block_in_place(|| {});
}
#[should_panic]
#[tokio::main(flavor = "current_thread")]
#[test]
async fn test_block_in_place3() {
tokio::task::block_in_place(|| {});
}
#[tokio::main]
#[test]
async fn test_block_in_place4() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:17 | .await
.unwrap()
});
}
}
// Testing the tuning logic is tricky as it is inherently timing based, and more
// of a heuristic than an exact behavior. This test checks that the interval
// changes over time based on load factors. There are no assertions, completion
// is sufficient. If there is a ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | rt.spawn(async move { iter(flag, counter, true) });
}
// Now, hammer the injection queue until the interval drops.
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
if curr <= 8 {
n += 1;
} else {
n = 0;
}
// Make sure we get a fe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(AtomicBool::new(true));
// Set it high, we know it shouldn't ever really be this high
let counter = Arc::new(AtomicUsize::new(10_000));
let interval = Arc::new(AtomicUsize::new(10_000))... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | std::thread::yield_now();
}
flag.store(false, Relaxed);
}
fn rt() -> runtime::Runtime {
runtime::Runtime::new().unwrap()
}
#[cfg(tokio_unstable)]
mod unstable {
use super::*;
#[test]
fn test_disable_lifo_slot() {
use std::sync::mpsc::{channel, RecvTimeoutError};
let rt = run... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:21 | handle.spawn(async {});
}
});
rt.block_on(async {
tokio::spawn(async {
// Spawn another task and block the thread until completion. If the LIFO slot
// is used then the test doesn't complete.
futures::executor::block_on(tokio::spaw... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded.rs | 801 | 836 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use futures::futur... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | let b = num_dec.load(Relaxed);
assert_eq!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
assert_eq!(c, 1);
}
}
#[test]
fn start_stop_callbacks_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
let after_start = Arc::new(AtomicUsize::n... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:9 | assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
fn blocking() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new(AtomicUsize::new(0));
// there are four workers i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:11 | // runtime worker yielded as part of `block_in_place` and guarantees the
// same thread will reclaim the worker at the end of the
// `block_in_place` call.
.max_blocking_threads(1)
.build()
.unwrap();
rt.block_on(async move {
let (tx, mut rx) = tokio::sync::mpsc::cha... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:12 | .await
.unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place then enter a new runtime
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:13 | #[test]
#[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread()
.max_blocking_threads(0)
.build()
.unwrap();
}
/// Regression test for #6445.
///
/// After #6445, setting `global_queue_interval` to 1 is now technically valid.
/// This te... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:15 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
let me = Pin::into_inner(self);
let mut lock = me.shared.lock().unwrap();
if me.put_waker {
lock.waker = Some(cx.waker().clone());
}
Poll::Pending
}
}
impl Drop ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:16 | #[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio::task::block_in_place(|| {});
}
#[should_panic]
#[tokio::main(flavor = "current_thread")]
#[test]
async fn test_block_in_place3() {
tokio::task::block_in_place(|| {});
}
#[tokio::main]
#[test]
async fn test_block_in_place4() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:17 | })
.await
.unwrap()
});
}
}
// Testing the tuning logic is tricky as it is inherently timing based, and more
// of a heuristic than an exact behavior. This test checks that the interval
// changes over time based on load factors. There are no assertions, completion
// is sufficient.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | let counter = counter.clone();
rt.spawn(async move { iter(flag, counter, true) });
}
// Now, hammer the injection queue until the interval drops.
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
if curr <= 8 {
n += 1;
} else {
n = 0;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(AtomicBool::new(true));
// Set it high, we know it shouldn't ever really be this high
let counter = Arc::new(AtomicUsize::new(10_000));
let interval... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | std::thread::yield_now();
}
flag.store(false, Relaxed);
}
fn rt() -> runtime::Runtime {
runtime::Runtime::new().unwrap()
}
#[cfg(tokio_unstable)]
mod unstable {
use super::*;
#[test]
fn test_disable_lifo_slot() {
use std::sync::mpsc::{channel, RecvTimeoutError};
let rt = run... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:21 | while recv.recv_timeout(one_sec) == Err(RecvTimeoutError::Timeout) {
handle.spawn(async {});
}
});
rt.block_on(async {
tokio::spawn(async {
// Spawn another task and block the thread until completion. If the LIFO slot
// is used th... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded.rs | 801 | 837 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use futures::futur... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use futures::future::poll_fn;
use std::future::Future;
use s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use futures::future::poll_fn;
use std::future::Future;
use s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:12 | .unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place then enter a new runtime
tokio::tas... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:13 | #[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread()
.max_blocking_threads(0)
.build()
.unwrap();
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn hang_on_shutdown() {
let (sync_tx, sync_rx) = std::sync::mpsc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:14 | };
let f2 = MyFuture {
shared,
put_waker: false,
};
(f1, f2)
}
}
impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
let me = Pin::into_inner(self)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:15 | rt.spawn(f1);
rt.spawn(f2);
rt.block_on(async { tokio::time::sleep(tokio::time::Duration::from_millis(20)).await });
}
#[should_panic]
#[tokio::test]
async fn test_block_in_place1() {
tokio::task::block_in_place(|| {});
}
#[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:16 | // Triggered by a race condition, so run a few times to make sure it is OK.
for _ in 0..100 {
let h = rt.handle().clone();
rt.block_on(async move {
tokio::spawn(async move {
tokio::task::block_in_place(|| {
h.block_on(async {
t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | });
std::thread::yield_now();
}
}
flag.store(false, Relaxed);
let w = Arc::downgrade(&interval);
drop(interval);
while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(Ato... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | }
if Arc::strong_count(&interval) <= 5_000 {
let counter = counter.clone();
let interval = interval.clone();
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});
}
std::thr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 310adf7ca69957703dc4b1c43f4932b26539bcc7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/310adf7ca69957703dc4b1c43f4932b26539bcc7/tokio/tests/rt_threaded.rs | 721 | 780 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.