mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
fix lints in miri
This commit is contained in:
parent
b0586843b2
commit
c48788270e
2 changed files with 26 additions and 26 deletions
|
@ -98,7 +98,7 @@ impl Runtime {
|
|||
}
|
||||
}
|
||||
|
||||
/// A gaurd for a new runtime. This must be used to override the current runtime when importing components from a dynamic library that has it's own runtime.
|
||||
/// A guard for a new runtime. This must be used to override the current runtime when importing components from a dynamic library that has it's own runtime.
|
||||
///
|
||||
/// ```rust
|
||||
/// use dioxus::prelude::*;
|
||||
|
|
|
@ -1,29 +1,12 @@
|
|||
//! Verify that tasks get polled by the virtualdom properly, and that we escape wait_for_work safely
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use std::{sync::atomic::AtomicUsize, time::Duration};
|
||||
|
||||
static POLL_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
#[cfg(not(miri))]
|
||||
#[tokio::test]
|
||||
async fn it_works() {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
use dioxus::prelude::*;
|
||||
use std::{sync::atomic::AtomicUsize, time::Duration};
|
||||
|
||||
let _ = dom.rebuild();
|
||||
|
||||
tokio::select! {
|
||||
_ = dom.wait_for_work() => {}
|
||||
_ = tokio::time::sleep(Duration::from_millis(500)) => {}
|
||||
};
|
||||
|
||||
// By the time the tasks are finished, we should've accumulated ticks from two tasks
|
||||
// Be warned that by setting the delay to too short, tokio might not schedule in the tasks
|
||||
assert_eq!(
|
||||
POLL_COUNT.fetch_add(0, std::sync::atomic::Ordering::Relaxed),
|
||||
135
|
||||
);
|
||||
}
|
||||
static POLL_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.use_hook(|| {
|
||||
|
@ -44,3 +27,20 @@ fn app(cx: Scope) -> Element {
|
|||
|
||||
cx.render(rsx!(()))
|
||||
}
|
||||
|
||||
let mut dom = VirtualDom::new(app);
|
||||
|
||||
let _ = dom.rebuild();
|
||||
|
||||
tokio::select! {
|
||||
_ = dom.wait_for_work() => {}
|
||||
_ = tokio::time::sleep(Duration::from_millis(500)) => {}
|
||||
};
|
||||
|
||||
// By the time the tasks are finished, we should've accumulated ticks from two tasks
|
||||
// Be warned that by setting the delay to too short, tokio might not schedule in the tasks
|
||||
assert_eq!(
|
||||
POLL_COUNT.fetch_add(0, std::sync::atomic::Ordering::Relaxed),
|
||||
135
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue