mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
runtime: fix yield_calls_park_before_scheduling_again test (#6679)
This commit is contained in:
@@ -35,7 +35,7 @@ tokio_thread_local! {
|
|||||||
// Bit of a hack, but it is only for loom
|
// Bit of a hack, but it is only for loom
|
||||||
#[cfg(loom)]
|
#[cfg(loom)]
|
||||||
tokio_thread_local! {
|
tokio_thread_local! {
|
||||||
static CURRENT_THREAD_PARK_COUNT: AtomicUsize = AtomicUsize::new(0);
|
pub(crate) static CURRENT_THREAD_PARK_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==== impl ParkThread ====
|
// ==== impl ParkThread ====
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ use crate::util::TryLock;
|
|||||||
use std::sync::atomic::Ordering::SeqCst;
|
use std::sync::atomic::Ordering::SeqCst;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
#[cfg(loom)]
|
||||||
|
use crate::runtime::park::CURRENT_THREAD_PARK_COUNT;
|
||||||
|
|
||||||
pub(crate) struct Parker {
|
pub(crate) struct Parker {
|
||||||
inner: Arc<Inner>,
|
inner: Arc<Inner>,
|
||||||
}
|
}
|
||||||
@@ -73,6 +76,13 @@ impl Parker {
|
|||||||
|
|
||||||
if let Some(mut driver) = self.inner.shared.driver.try_lock() {
|
if let Some(mut driver) = self.inner.shared.driver.try_lock() {
|
||||||
driver.park_timeout(handle, duration);
|
driver.park_timeout(handle, duration);
|
||||||
|
} else {
|
||||||
|
// https://github.com/tokio-rs/tokio/issues/6536
|
||||||
|
// Hacky, but it's just for loom tests. The counter gets incremented during
|
||||||
|
// `park_timeout`, but we still have to increment the counter if we can't acquire the
|
||||||
|
// lock.
|
||||||
|
#[cfg(loom)]
|
||||||
|
CURRENT_THREAD_PARK_COUNT.with(|count| count.fetch_add(1, SeqCst));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use crate::runtime::tests::loom_oneshot as oneshot;
|
|||||||
use crate::runtime::{self, Runtime};
|
use crate::runtime::{self, Runtime};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
|
||||||
fn yield_calls_park_before_scheduling_again() {
|
fn yield_calls_park_before_scheduling_again() {
|
||||||
// Don't need to check all permutations
|
// Don't need to check all permutations
|
||||||
let mut loom = loom::model::Builder::default();
|
let mut loom = loom::model::Builder::default();
|
||||||
|
|||||||
Reference in New Issue
Block a user