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/src/runtime/tests/loom_basic_scheduler.rs:4 | }
struct ResetFuture {
rx: Receiver<()>,
pending_cnt: Arc<AtomicUsize>,
}
impl Future for ResetFuture {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match Pin::new(&mut self.rx).poll(cx) {
Poll::Pending => {
self... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_basic_scheduler.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/tests/loom_basic_scheduler.rs | 121 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_basic_scheduler.rs:2 | // - when we fail to steal the parker and we block on a
// notification that it is available.
//
// - when we steal the parker and we schedule the future
//
// - when the future is woken up and we have ran the max
// number of tasks for the current tick or there are n... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_basic_scheduler.rs | MIT | e6a9167bb7012f23640f5022bd97740d7829c4b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e6a9167bb7012f23640f5022bd97740d7829c4b1/tokio/src/runtime/tests/loom_basic_scheduler.rs | 41 | 82 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:1 | use crate::runtime::{self, Runtime};
use std::sync::Arc;
use std::time::Duration;
#[test]
fn blocking_shutdown() {
loom::model(|| {
let v = Arc::new(());
let rt = mk_runtime(1);
{
let _enter = rt.enter();
for _ in 0..2 {
let v = v.clone();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:2 | drop(rt);
// This call will deadlock if `spawn_mandatory_blocking` doesn't run.
let () = rx.recv();
});
}
#[test]
fn spawn_mandatory_blocking_should_run_even_when_shutting_down_from_other_thread() {
use crate::runtime::tests::loom_oneshot;
loom::model(|| {
let rt = runtime::Builder... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:3 | .enable_time()
.start_paused(true)
.build()
.unwrap();
let handle = rt.handle();
let _enter = handle.enter();
let a = crate::task::spawn_blocking(|| {});
let b = crate::task::spawn_blocking(|| {});
rt.block_on(crate::time::timeout(Duration::fro... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_blocking.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:4 | // shutdown the runtime, which also shutdown the blocking pool
drop(rt);
// loom will emulate two parrel operations:
//
// 1. the blocking thread is woken up on the condvar
// 2. the main thread is waiting for the blocking thread to finish the task
//
// So, if t... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_blocking.rs | 121 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:1 | use crate::runtime::{self, Runtime};
use std::sync::Arc;
#[test]
fn blocking_shutdown() {
loom::model(|| {
let v = Arc::new(());
let rt = mk_runtime(1);
{
let _enter = rt.enter();
for _ in 0..2 {
let v = v.clone();
crate::task::spawn... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/loom_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:2 | // This call will deadlock if `spawn_mandatory_blocking` doesn't run.
let () = rx.recv();
});
}
#[test]
fn spawn_mandatory_blocking_should_run_even_when_shutting_down_from_other_thread() {
use crate::runtime::tests::loom_oneshot;
loom::model(|| {
let rt = runtime::Builder::new_current_threa... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/loom_blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:3 | .enable_time()
.start_paused(true)
.build()
.unwrap();
let handle = rt.handle();
let _enter = handle.enter();
let a = crate::task::spawn_blocking(|| {});
let b = crate::task::spawn_blocking(|| {});
rt.block_on(crate::time::timeout(Duration::fro... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/loom_blocking.rs | 81 | 102 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:2 | // This call will deadlock if `spawn_mandatory_blocking` doesn't run.
let () = rx.recv();
});
}
#[test]
fn spawn_mandatory_blocking_should_run_even_when_shutting_down_from_other_thread() {
use crate::runtime::tests::loom_oneshot;
loom::model(|| {
let rt = runtime::Builder::new_current_threa... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | 7aad428994120b2b37cdbefd7b1dd351555c92a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7aad428994120b2b37cdbefd7b1dd351555c92a3/tokio/src/runtime/tests/loom_blocking.rs | 41 | 81 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:1 | use crate::runtime::{self, Runtime};
use std::sync::Arc;
#[test]
fn blocking_shutdown() {
loom::model(|| {
let v = Arc::new(());
let rt = mk_runtime(1);
{
let _enter = rt.enter();
for _ in 0..2 {
let v = v.clone();
crate::task::spawn... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | 00b6127f2ed3125f8b305ab4fd9bb90e99762785 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/src/runtime/tests/loom_blocking.rs | 1 | 31 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:1 | use crate::runtime::{self, Runtime};
use std::sync::Arc;
#[test]
fn blocking_shutdown() {
loom::model(|| {
let v = Arc::new(());
let rt = mk_runtime(1);
rt.enter(|| {
for _ in 0..2 {
let v = v.clone();
crate::task::spawn_blocking(move || {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/tests/loom_blocking.rs | 1 | 30 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:1 | use crate::runtime::{self, Runtime};
use std::sync::Arc;
#[test]
fn blocking_shutdown() {
loom::model(|| {
let v = Arc::new(());
let rt = mk_runtime(1);
rt.enter(|| {
for _ in 0..2 {
let v = v.clone();
crate::task::spawn_blocking(move || {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | b24ad9fe861ce01add2c6533149f643e38537f59 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b24ad9fe861ce01add2c6533149f643e38537f59/tokio/src/runtime/tests/loom_blocking.rs | 1 | 31 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_blocking.rs:1 | use crate::runtime::{self, Runtime};
use std::sync::Arc;
#[test]
fn blocking_shutdown() {
loom::model(|| {
let v = Arc::new(());
let rt = mk_runtime(1);
rt.enter(|| {
for _ in 0..2 {
let v = v.clone();
crate::task::spawn_blocking(move || {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_blocking.rs | MIT | 83cd754bc80dc8718b65fd32f54e53b4d7ba8332 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/83cd754bc80dc8718b65fd32f54e53b4d7ba8332/tokio/src/runtime/tests/loom_blocking.rs | 1 | 31 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_current_thread.rs:1 | mod yield_now;
use crate::loom::sync::atomic::{AtomicUsize, Ordering};
use crate::loom::sync::Arc;
use crate::loom::thread;
use crate::runtime::{Builder, Runtime};
use crate::sync::oneshot::{self, Receiver};
use crate::task;
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::Ordering::{Acquire, Release... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_current_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_current_thread.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_current_thread.rs:2 | // any of these points it can be ready:
//
// - when we fail to steal the parker and we block on a notification
// that it is available.
//
// - when we steal the parker and we schedule the future
//
// - when the future is woken up and we have ran the max numbe... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_current_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_current_thread.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_current_thread.rs:3 | }
tx.send(()).unwrap();
});
let pending_cnt_clone = pending_cnt.clone();
rt.block_on(async move {
// use task::yield_now() to ensure woken set to true
// ResetFuture will be polled at most once
// Here comes two cases
// 1. recv no mes... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_current_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_current_thread.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_current_thread.rs:4 | static VTABLE: RawWakerVTable =
RawWakerVTable::new(waker_clone, waker_drop, waker_nop, waker_drop);
loom::model(|| {
let rt = Builder::new_current_thread().build().unwrap();
let mut jh = rt.spawn(async {});
// Using AbortHandle to increment task refcount. This ensures that the wak... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_current_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_current_thread.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_current_thread.rs:5 | }
struct BlockedFuture {
rx: Receiver<()>,
num_polls: Arc<AtomicUsize>,
}
impl Future for BlockedFuture {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.num_polls.fetch_add(1, Release);
match Pin::new(&mut self.rx).poll(cx) {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_current_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_current_thread.rs | 161 | 198 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_current_thread/yield_now.rs:1 | use crate::runtime::park;
use crate::runtime::{self, Runtime};
#[test]
fn yield_calls_park_before_scheduling_again() {
// Don't need to check all permutations
let mut loom = loom::model::Builder::default();
loom.max_permutations = Some(1);
loom.check(|| {
let rt = mk_runtime();
let jh ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_current_thread/yield_now.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_current_thread/yield_now.rs | 1 | 30 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_join_set.rs:1 | use crate::runtime::Builder;
use crate::task::JoinSet;
#[test]
fn test_join_set() {
loom::model(|| {
let rt = Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
let mut set = JoinSet::new();
rt.block_on(async {
assert_eq!(set.... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_join_set.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_join_set.rs:2 | };
// These booleans assert that at least one execution had the task complete first, and that at
// least one execution had the task be cancelled before it completed.
let complete_happened = Arc::new(AtomicBool::new(false));
let cancel_happened = Arc::new(AtomicBool::new(false));
{
let com... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_join_set.rs | 41 | 82 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_join_set.rs:1 | #![cfg(tokio_unstable)]
use crate::runtime::Builder;
use crate::task::JoinSet;
#[test]
fn test_join_set() {
loom::model(|| {
let rt = Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
let mut set = JoinSet::new();
rt.block_on(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_join_set.rs | MIT | 55078ffec3bba78803ff646f3933a23834789e4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/55078ffec3bba78803ff646f3933a23834789e4e/tokio/src/runtime/tests/loom_join_set.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_join_set.rs:2 | Arc,
};
// These booleans assert that at least one execution had the task complete first, and that at
// least one execution had the task be cancelled before it completed.
let complete_happened = Arc::new(AtomicBool::new(false));
let cancel_happened = Arc::new(AtomicBool::new(false));
{
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_join_set.rs | MIT | 55078ffec3bba78803ff646f3933a23834789e4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/55078ffec3bba78803ff646f3933a23834789e4e/tokio/src/runtime/tests/loom_join_set.rs | 41 | 83 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_join_set.rs:1 | use crate::runtime::Builder;
use crate::task::JoinSet;
#[test]
fn test_join_set() {
loom::model(|| {
let rt = Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
let mut set = JoinSet::new();
rt.block_on(async {
assert_eq!(set.... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_join_set.rs | MIT | 5fd1220c7302ec2291699939a8f6cda210ef7bae | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5fd1220c7302ec2291699939a8f6cda210ef7bae/tokio/src/runtime/tests/loom_join_set.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_join_set.rs:2 | };
// These booleans assert that at least one execution had the task complete first, and that at
// least one execution had the task be cancelled before it completed.
let complete_happened = Arc::new(AtomicBool::new(false));
let cancel_happened = Arc::new(AtomicBool::new(false));
{
let com... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_join_set.rs | MIT | 5fd1220c7302ec2291699939a8f6cda210ef7bae | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5fd1220c7302ec2291699939a8f6cda210ef7bae/tokio/src/runtime/tests/loom_join_set.rs | 41 | 82 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_join_set.rs:2 | };
// These booleans assert that at least one execution had the task complete first, and that at
// least one execution had the task be cancelled before it completed.
let complete_happened = Arc::new(AtomicBool::new(false));
let cancel_happened = Arc::new(AtomicBool::new(false));
{
let com... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_join_set.rs | MIT | 1bb4d2316232a77d048e8797ba04d796911ffe30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bb4d2316232a77d048e8797ba04d796911ffe30/tokio/src/runtime/tests/loom_join_set.rs | 41 | 82 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_local.rs:1 | use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::Builder;
use crate::task::LocalSet;
use std::task::Poll;
/// Waking a runtime will attempt to push a task into a queue of notifications
/// in the runtime, however the tasks in such a queue usually have a reference
/// to the runtime itself. This... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_local.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_local.rs | 1 | 47 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_local.rs:1 | use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::Builder;
use crate::task::LocalSet;
use std::task::Poll;
/// Waking a runtime will attempt to push a task into a queue of notifications
/// in the runtime, however the tasks in such a queue usually have a reference
/// to the runtime itself. This... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_local.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/tests/loom_local.rs | 1 | 47 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_local.rs:1 | use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::Builder;
use crate::task::LocalSet;
use std::task::Poll;
/// Waking a runtime will attempt to push a task into a queue of notifications
/// in the runtime, however the tasks in such a queue usually have a reference
/// to the runtime itself. This... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_local.rs | MIT | 998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5/tokio/src/runtime/tests/loom_local.rs | 1 | 47 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:1 | mod queue;
mod shutdown;
mod yield_now;
/// Full runtime loom tests. These are heavy tests and take significant time to
/// run on CI.
///
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
///
/// In order to speed up the C
use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::{se... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:2 | }
pub(super) fn take(&self) -> Option<T> {
// safety: Only one thread will see the boolean change from false
// to true, so that thread is able to take the value.
match self.taken.fetch_or(true, SeqCst) {
false => unsafe { Some(std::ptr::read(self.inner.as_pt... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:3 | fn racy_shutdown() {
loom::model(|| {
let pool = mk_pool(1);
// here's the case we want to exercise:
//
// a worker that still has tasks in its local queue gets sent to the blocking pool (due to
// block_in_place). the blocking pool is shut down, so d... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:4 | // Spawn a second task
pool.spawn(track(async move {
spawn(track(async move {
if 1 == c2.fetch_add(1, Relaxed) {
tx2.assert_send(());
}
}));
}));
rx.recv();
});
}
fn only... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:5 | only_blocking_inner(true)
}
}
mod group_b {
use super::*;
fn blocking_and_regular_inner(first_pending: bool) {
const NUM: usize = 3;
loom::model(move || {
let pool = mk_pool(1);
let cnt = Arc::new(AtomicUsize::new(0));
let (block_tx, block_rx) = oneshot... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:6 | drop(pool);
});
}
#[test]
fn blocking_and_regular() {
blocking_and_regular_inner(false);
}
#[test]
fn blocking_and_regular_with_pending() {
blocking_and_regular_inner(true);
}
#[test]
fn join_output() {
loom::model(|| {
let rt = mk_pool(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:7 | .await;
});
})
}
#[test]
fn complete_block_on_under_load() {
loom::model(|| {
let pool = mk_pool(1);
pool.block_on(async {
// Trigger a re-schedule
crate::spawn(track(async {
for _ in 0..2 {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:8 | });
let _ = rx.await;
let _ = done_tx.send(());
}));
});
}
}
mod group_c {
use super::*;
#[test]
fn pool_shutdown() {
loom::model(|| {
let pool = mk_pool(2);
pool.spawn(track(async move {
gated2(true... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:9 | let (done_tx, done_rx) = oneshot::channel();
let done_tx1 = AtomicOneshot::new(done_tx);
let done_tx2 = done_tx1.clone();
// Spawn a task
let c2 = c1.clone();
pool.spawn(track(async move {
multi_gated().await;
if 1 == c1.fetch... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:10 | use std::sync::Arc;
let gate = Arc::new(AtomicBool::new(false));
let mut fired = false;
poll_fn(move |cx| {
if !fired {
let gate = gate.clone();
let waker = cx.waker().clone();
if thread {
thread::spawn(move || {
gate.store(t... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:11 | let gate = Arc::new(Gate {
waker: loom::future::AtomicWaker::new(),
count: AtomicUsize::new(0),
});
{
let gate = gate.clone();
spawn(track(async move {
for i in 1..3 {
gate.count.store(i, SeqCst);
gate.waker.wake();
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:12 | }
}
impl<T> Track<T> {
fn into_inner(self) -> T {
self.inner
}
}
impl<T: Future> Future for Track<T> {
type Output = Track<T::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let me = self.project();
Poll::Ready(Track {
inner: r... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread.rs | 441 | 461 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:1 | mod queue;
mod shutdown;
mod yield_now;
/// Full runtime loom tests. These are heavy tests and take significant time to
/// run on CI.
///
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
///
/// In order to speed up the C
use crate::future::poll_fn;
use crate::runtime::tests::loom_oneshot as ones... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:2 | }
}
pub(super) fn take(&self) -> Option<T> {
// safety: Only one thread will see the boolean change from false
// to true, so that thread is able to take the value.
match self.taken.fetch_or(true, SeqCst) {
false => unsafe { Some(std::ptr::read(self.i... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:4 | }));
// Spawn a second task
pool.spawn(track(async move {
spawn(track(async move {
if 1 == c2.fetch_add(1, Relaxed) {
tx2.assert_send(());
}
}));
}));
rx.recv();
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:5 | fn only_blocking_with_pending() {
only_blocking_inner(true)
}
}
mod group_b {
use super::*;
fn blocking_and_regular_inner(first_pending: bool) {
const NUM: usize = 3;
loom::model(move || {
let pool = mk_pool(1);
let cnt = Arc::new(AtomicUsize::new(0));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:6 | drop(pool);
});
}
#[test]
fn blocking_and_regular() {
blocking_and_regular_inner(false);
}
#[test]
fn blocking_and_regular_with_pending() {
blocking_and_regular_inner(true);
}
#[test]
fn join_output() {
loom::model(|| {
let rt = mk_pool(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:7 | })
.await;
});
})
}
#[test]
fn complete_block_on_under_load() {
loom::model(|| {
let pool = mk_pool(1);
pool.block_on(async {
// Trigger a re-schedule
crate::spawn(track(async {
for _ in... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:8 | let _ = done_rx.await;
});
let _ = rx.await;
let _ = done_tx.send(());
}));
});
}
}
mod group_c {
use super::*;
#[test]
fn pool_shutdown() {
loom::model(|| {
let pool = mk_pool(2);
pool.spawn(track(a... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:9 | let c1 = Arc::new(AtomicUsize::new(0));
let (done_tx, done_rx) = oneshot::channel();
let done_tx1 = AtomicOneshot::new(done_tx);
let done_tx2 = done_tx1.clone();
// Spawn a task
let c2 = c1.clone();
pool.spawn(track(async move {
m... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:10 | use loom::thread;
use std::sync::Arc;
let gate = Arc::new(AtomicBool::new(false));
let mut fired = false;
poll_fn(move |cx| {
if !fired {
let gate = gate.clone();
let waker = cx.waker().clone();
if thread {
thread::spawn(move || {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:11 | }
let gate = Arc::new(Gate {
waker: loom::future::AtomicWaker::new(),
count: AtomicUsize::new(0),
});
{
let gate = gate.clone();
spawn(track(async move {
for i in 1..3 {
gate.count.store(i, SeqCst);
gate.waker.wake();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread.rs:12 | arc: Arc<()>,
}
}
impl<T> Track<T> {
fn into_inner(self) -> T {
self.inner
}
}
impl<T: Future> Future for Track<T> {
type Output = Track<T::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let me = self.project();
Poll::Ready(Track {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread.rs | 441 | 462 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:1 | use crate::runtime::scheduler::multi_thread::{queue, Stats};
use crate::runtime::tests::{unowned, NoopSchedule};
use loom::thread;
use std::cell::RefCell;
fn new_stats() -> Stats {
Stats::new(&crate::runtime::WorkerMetrics::new())
}
#[test]
fn basic() {
loom::model(|| {
let (steal, mut local) = queue... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:2 | local.push_back_or_overflow(task, &inject, &mut stats);
}
if local.pop().is_some() {
n += 1;
}
// Push another task
let (task, _) = unowned(async {});
local.push_back_or_overflow(task, &inject, &mut stats);
while loca... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:3 | while local.pop().is_some() {
n += 1;
}
n
});
let mut n = 0;
// push a task, pop a task
let (task, _) = unowned(async {});
local.push_back_or_overflow(task, &inject, &mut stats);
if local.pop().is_some() {
n += 1;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:4 | let (_, mut local) = queue::local();
if steal.steal_into(&mut local, &mut stats).is_none() {
return 0;
}
let mut n = 1;
while local.pop().is_some() {
n += 1;
}
n
}
loom::model(|| {
let (steal, mut local) = queue::local();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:5 | n += th1.join().unwrap();
n += th2.join().unwrap();
assert_eq!(n, NUM_TASKS);
});
}
#[test]
fn chained_steal() {
loom::model(|| {
let mut stats = new_stats();
let (s1, mut l1) = queue::local();
let (s2, mut l2) = queue::local();
let inject = RefCell::new(vec![])... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 161 | 205 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:2 | local.push_back_or_overflow(task, &inject, &mut stats);
}
if local.pop().is_some() {
n += 1;
}
// Push another task
let (task, _) = unowned(async {});
local.push_back_or_overflow(task, &inject, &mut stats);
while loca... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:3 | }
while local.pop().is_some() {
n += 1;
}
}
n
});
let mut n = 0;
for _ in 0..2 {
for _ in 0..2 {
let (task, _) = unowned(async {});
if let Some(prev) = local.push_lifo(task... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:4 | });
}
#[test]
fn steal_overflow() {
loom::model(|| {
let (steal, mut local) = queue::local();
let inject = RefCell::new(vec![]);
let mut stats = new_stats();
let th = thread::spawn(move || {
let mut stats = new_stats();
let (_, mut local) = queue::local();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:5 | n += th.join().unwrap();
while local.pop().is_some() {
n += 1;
}
n += inject.borrow_mut().drain(..).count();
assert_eq!(7, n);
});
}
#[test]
fn multi_stealer() {
const NUM_TASKS: usize = 5;
loom::model(|| {
let (steal, mut local) = queue::local();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:6 | n += inject.borrow_mut().drain(..).count();
n += th1.join().unwrap();
n += th2.join().unwrap();
assert_eq!(n, NUM_TASKS);
});
}
// Like `multi_stealer`, but with tasks in the LIFO slot.
#[test]
fn multi_stealer_lifo() {
const NUM_TASKS: usize = 5;
loom::model(|| {
let (st... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:7 | while local.pop_lifo().or_else(|| local.pop()).is_some() {
n += 1;
}
n += inject.borrow_mut().drain(..).count();
n += th1.join().unwrap();
n += th2.join().unwrap();
assert_eq!(n, NUM_TASKS);
});
}
fn steal_tasks(steal: queue::Steal<NoopSchedule>) -> usize {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/queue.rs:8 | for _ in 0..4 {
let (task, _) = unowned(async {});
l1.push_back_or_overflow(task, &inject, &mut stats);
let (task, _) = unowned(async {});
l2.push_back_or_overflow(task, &inject, &mut stats);
}
// Spawn a task to steal from **our** queue
let th =... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/queue.rs | MIT | eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/tests/loom_multi_thread/queue.rs | 281 | 308 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/shutdown.rs:1 | use crate::runtime::{Builder, Handle};
#[test]
fn join_handle_cancel_on_shutdown() {
let mut builder = loom::model::Builder::new();
builder.preemption_bound = Some(2);
builder.check(|| {
use futures::future::FutureExt;
let rt = Builder::new_multi_thread()
.worker_threads(2)
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/shutdown.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread/shutdown.rs | 1 | 28 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/yield_now.rs:1 | use crate::runtime::park;
use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::{self, Runtime};
#[test]
fn yield_calls_park_before_scheduling_again() {
// Don't need to check all permutations
let mut loom = loom::model::Builder::default();
loom.max_permutations = Some(1);
loom.check(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/yield_now.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/loom_multi_thread/yield_now.rs | 1 | 37 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread/yield_now.rs:1 | use crate::runtime::park;
use crate::runtime::tests::loom_oneshot as oneshot;
use crate::runtime::{self, Runtime};
#[test]
#[ignore]
fn yield_calls_park_before_scheduling_again() {
// Don't need to check all permutations
let mut loom = loom::model::Builder::default();
loom.max_permutations = Some(1);
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread/yield_now.rs | MIT | 75e5b3d96d126b52a510ad19e79cf1e4445770e0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/75e5b3d96d126b52a510ad19e79cf1e4445770e0/tokio/src/runtime/tests/loom_multi_thread/yield_now.rs | 1 | 38 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:1 | #![cfg(tokio_unstable)]
mod queue;
mod shutdown;
mod yield_now;
/// Full runtime loom tests. These are heavy tests and take significant time to
/// run on CI.
///
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
///
/// In order to speed up the C
use crate::runtime::tests::loom_oneshot as oneshot... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:2 | taken: AtomicBool::new(false),
}
}
pub(super) fn take(&self) -> Option<T> {
// safety: Only one thread will see the boolean change from false
// to true, so that thread is able to take the value.
match self.taken.fetch_or(true, SeqCst) {
f... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:3 | #[test]
fn racy_shutdown() {
loom::model(|| {
let pool = mk_pool(1);
// here's the case we want to exercise:
//
// a worker that still has tasks in its local queue gets sent to the blocking pool (due to
// block_in_place). the blocking pool is shu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:4 | }));
}));
// Spawn a second task
pool.spawn(track(async move {
spawn(track(async move {
if 1 == c2.fetch_add(1, Relaxed) {
tx2.assert_send(());
}
}));
}));
rx.rec... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:5 | #[test]
fn only_blocking_with_pending() {
only_blocking_inner(true)
}
}
mod group_b {
use super::*;
fn blocking_and_regular_inner(first_pending: bool) {
const NUM: usize = 3;
loom::model(move || {
let pool = mk_pool(1);
let cnt = Arc::new(AtomicUsize::ne... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:6 | block_rx.recv();
drop(pool);
});
}
#[test]
#[ignore] // TODO: uncomment
fn blocking_and_regular_without_pending() {
blocking_and_regular_inner(false);
}
#[test]
fn blocking_and_regular_with_pending() {
blocking_and_regular_inner(true);
}
#[test... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:7 | let _ = Pin::new(&mut t).poll(cx);
Poll::Ready(())
})
.await;
});
})
}
#[test]
fn complete_block_on_under_load() {
loom::model(|| {
let pool = mk_pool(1);
pool.block_on(async {
// Trigge... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:8 | });
let _ = done_rx.await;
});
let _ = rx.await;
let _ = done_tx.send(());
}));
});
}
}
mod group_c {
use super::*;
#[test]
fn pool_shutdown() {
loom::model(|| {
let pool = mk_pool(2);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:9 | let tx = AtomicOneshot::new(tx);
let pool = runtime::Builder::new_multi_thread_alt()
.worker_threads(2)
// Set the intervals to avoid tuning logic
.global_queue_interval(61)
.local_queue_capacity(1)
.build()
.un... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:10 | .global_queue_interval(61)
.local_queue_capacity(DEPTH)
.build()
.unwrap();
// Use std types to avoid adding backtracking.
type Flag = std::sync::Arc<std::sync::atomic::AtomicIsize>;
let flag: Flag = Default::default();
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:11 | loom::stop_exploring();
let (tx3, rx3) = oneshot::channel();
pool.spawn(async move {
loom::skip_branch();
tx3.send(());
});
pool.spawn(async {});
pool.spawn(async {});
loom::explore... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:12 | if 1 == c1.fetch_add(1, Relaxed) {
done_tx1.assert_send(());
}
}));
// Spawn a second task
pool.spawn(track(async move {
multi_gated().await;
if 1 == c2.fetch_add(1, Relaxed) {
done_tx2.assert_s... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:13 | if thread {
thread::spawn(move || {
gate.store(true, SeqCst);
waker.wake_by_ref();
});
} else {
spawn(track(async move {
gate.store(true, SeqCst);
waker.wake_by_ref();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:14 | gate.count.store(i, SeqCst);
gate.waker.wake();
}
}));
}
poll_fn(move |cx| {
gate.waker.register_by_ref(cx.waker());
if gate.count.load(SeqCst) < 2 {
Poll::Pending
} else {
Poll::Ready(())
}
})
.await;
}
fn tra... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 521 | 571 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:15 | type Output = Track<T::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let me = self.project();
Poll::Ready(Track {
inner: ready!(me.inner.poll(cx)),
arc: me.arc.clone(),
})
}
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 561 | 571 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:1 | #![cfg(tokio_unstable)]
mod queue;
mod shutdown;
mod yield_now;
/// Full runtime loom tests. These are heavy tests and take significant time to
/// run on CI.
///
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
///
/// In order to speed up the C
use crate::future::poll_fn;
use crate::runtime::te... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:2 | inner: MaybeUninit::new(value),
taken: AtomicBool::new(false),
}
}
pub(super) fn take(&self) -> Option<T> {
// safety: Only one thread will see the boolean change from false
// to true, so that thread is able to take the value.
match self.... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:3 | use super::*;
#[test]
fn racy_shutdown() {
loom::model(|| {
let pool = mk_pool(1);
// here's the case we want to exercise:
//
// a worker that still has tasks in its local queue gets sent to the blocking pool (due to
// block_in_place). the b... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:4 | }
}));
}));
// Spawn a second task
pool.spawn(track(async move {
spawn(track(async move {
if 1 == c2.fetch_add(1, Relaxed) {
tx2.assert_send(());
}
}));
}));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:5 | #[test]
fn only_blocking_with_pending() {
only_blocking_inner(true)
}
}
mod group_b {
use super::*;
fn blocking_and_regular_inner(first_pending: bool) {
const NUM: usize = 3;
loom::model(move || {
let pool = mk_pool(1);
let cnt = Arc::new(AtomicUsize::ne... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:6 | done_rx.recv();
block_rx.recv();
drop(pool);
});
}
#[test]
#[ignore] // TODO: uncomment
fn blocking_and_regular_without_pending() {
blocking_and_regular_inner(false);
}
#[test]
fn blocking_and_regular_with_pending() {
blocking_and_regular_in... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:7 | poll_fn(|cx| {
let _ = Pin::new(&mut t).poll(cx);
Poll::Ready(())
})
.await;
});
})
}
#[test]
fn complete_block_on_under_load() {
loom::model(|| {
let pool = mk_pool(1);
pool.block_o... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:8 | let _ = tx.send(());
});
let _ = done_rx.await;
});
let _ = rx.await;
let _ = done_tx.send(());
}));
});
}
}
mod group_c {
use super::*;
#[test]
fn pool_shutdown() {
loom::model(|| {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:9 | let (tx, rx) = oneshot::channel();
let tx = AtomicOneshot::new(tx);
let pool = runtime::Builder::new_multi_thread_alt()
.worker_threads(2)
// Set the intervals to avoid tuning logic
.global_queue_interval(61)
.local_queue_capacity(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:10 | // Set the intervals to avoid tuning logic
.global_queue_interval(61)
.local_queue_capacity(DEPTH)
.build()
.unwrap();
// Use std types to avoid adding backtracking.
type Flag = std::sync::Arc<std::sync::atomic::AtomicIsize>;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:11 | if 1 == flag.load(Relaxed) {
loom::stop_exploring();
let (tx3, rx3) = oneshot::channel();
pool.spawn(async move {
loom::skip_branch();
tx3.send(());
});
pool.spawn(async {});
pool.sp... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:12 | if 1 == c1.fetch_add(1, Relaxed) {
done_tx1.assert_send(());
}
}));
// Spawn a second task
pool.spawn(track(async move {
multi_gated().await;
if 1 == c2.fetch_add(1, Relaxed) {
done_tx2.assert_s... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:13 | if thread {
thread::spawn(move || {
gate.store(true, SeqCst);
waker.wake_by_ref();
});
} else {
spawn(track(async move {
gate.store(true, SeqCst);
waker.wake_by_ref();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:14 | for i in 1..3 {
gate.count.store(i, SeqCst);
gate.waker.wake();
}
}));
}
poll_fn(move |cx| {
gate.waker.register_by_ref(cx.waker());
if gate.count.load(SeqCst) < 2 {
Poll::Pending
} else {
Poll::Ready(())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 521 | 572 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:15 | impl<T: Future> Future for Track<T> {
type Output = Track<T::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let me = self.project();
Poll::Ready(Track {
inner: ready!(me.inner.poll(cx)),
arc: me.arc.clone(),
})
}
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 561 | 572 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:1 | #![cfg(tokio_unstable)]
mod queue;
mod shutdown;
mod yield_now;
/// Full runtime loom tests. These are heavy tests and take significant time to
/// run on CI.
///
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
///
/// In order to speed up the C
use crate::future::poll_fn;
use crate::runtime::te... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | bd51feac474c3d08868a70dd7f262d37780a5370 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bd51feac474c3d08868a70dd7f262d37780a5370/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/loom_multi_thread_alt.rs:1 | mod queue;
mod shutdown;
mod yield_now;
/// Full runtime loom tests. These are heavy tests and take significant time to
/// run on CI.
///
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
///
/// In order to speed up the C
use crate::future::poll_fn;
use crate::runtime::tests::loom_oneshot as ones... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/loom_multi_thread_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/src/runtime/tests/loom_multi_thread_alt.rs | 1 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.