🎨 Make the let-go tests pass clippy
The pages-job test's rig needs no mut, and the shared-flush test spawns its threads and reads its clock through the video crate's runtime, as the crate's lints ask, instead of std's.
This commit is contained in:
1 parent
96efb6092c
commit
be2e87faf4
2 files changed
+11
-5
No files matched your search
@@ -6,7 +6,7 @@ use std::path::PathBuf;
|
||||
use std::ptr::null_mut;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::core::runtime::{Runtime as _, StdRuntime};
|
||||
|
||||
@@ -439,15 +439,21 @@ fn pairs_let_go_together_share_one_flush() {
|
||||
let threads: Vec<_> = (pairs.into_iter())
|
||||
.map(|pair| {
|
||||
let returned = Arc::clone(&returned);
|
||||
std::thread::spawn(move || {
|
||||
StdRuntime::thread("pair-drop", move || {
|
||||
drop(pair);
|
||||
returned.fetch_add(1, Ordering::SeqCst);
|
||||
})
|
||||
.expect("a thread")
|
||||
})
|
||||
.collect();
|
||||
let deadline = Instant::now() + Duration::from_secs(10);
|
||||
// The tests' clock: std's, which the library does not read.
|
||||
let clock = StdRuntime;
|
||||
let asked = clock.now();
|
||||
while draw.flushes.owed.lock().asked < 4 {
|
||||
assert!(Instant::now() < deadline, "the four pairs ask for a flush");
|
||||
assert!(
|
||||
clock.elapsed_since(asked) < Duration::from_secs(10),
|
||||
"the four pairs ask for a flush"
|
||||
);
|
||||
std::thread::sleep(Duration::from_millis(1));
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(20));
|
||||
|
||||
@@ -10493,7 +10493,7 @@ pub(super) mod tests {
|
||||
/// `SURFACE_PAGES` waited about half a second for a thread
|
||||
#[test]
|
||||
fn a_pages_job_made_while_released_caches_wait_to_go_does_not_wait_for_them() {
|
||||
let mut r = cached();
|
||||
let r = cached();
|
||||
let cache = reims_vgpu_vulkan::core::platform::ObjId(cache_id(&r));
|
||||
r.dec.let_go_worker().hold();
|
||||
r.dec
|
||||
|
||||
Reference in new issue
Block a user