all: replace standard sync types by parking_lot
Mostly because we'll start using egui which already has a dependency on parking_lot.
This commit is contained in:
parent
a474033bff
commit
2a9c746781
4 changed files with 164 additions and 82 deletions
14
src/it.rs
14
src/it.rs
|
|
@ -14,13 +14,9 @@ use {
|
|||
futures_util::{future, future::Either},
|
||||
isnt::std_1::collections::IsntHashMapExt,
|
||||
log::Level,
|
||||
parking_lot::Mutex,
|
||||
std::{
|
||||
cell::Cell,
|
||||
collections::VecDeque,
|
||||
future::pending,
|
||||
pin::Pin,
|
||||
rc::Rc,
|
||||
sync::{Arc, Mutex},
|
||||
cell::Cell, collections::VecDeque, future::pending, pin::Pin, rc::Rc, sync::Arc,
|
||||
time::SystemTime,
|
||||
},
|
||||
uapi::c,
|
||||
|
|
@ -75,7 +71,7 @@ pub fn run_tests() {
|
|||
let queue = queue.clone();
|
||||
let it_run = it_run.clone();
|
||||
threads.push(std::thread::spawn(move || loop {
|
||||
let test = match queue.lock().unwrap().pop_front() {
|
||||
let test = match queue.lock().pop_front() {
|
||||
Some(t) => t,
|
||||
_ => break,
|
||||
};
|
||||
|
|
@ -88,7 +84,7 @@ pub fn run_tests() {
|
|||
thread.join().unwrap();
|
||||
}
|
||||
}
|
||||
let failed = it_run.failed.lock().unwrap();
|
||||
let failed = it_run.failed.lock();
|
||||
if failed.is_not_empty() {
|
||||
let mut failed: Vec<_> = failed.iter().collect();
|
||||
failed.sort_by_key(|f| f.0);
|
||||
|
|
@ -167,7 +163,7 @@ fn run_test(it_run: &ItRun, test: &'static dyn TestCase, cfg: Rc<TestConfig>) {
|
|||
for e in &errors {
|
||||
log::error!(" {}", e);
|
||||
}
|
||||
it_run.failed.lock().unwrap().insert(test.name(), errors);
|
||||
it_run.failed.lock().insert(test.name(), errors);
|
||||
}
|
||||
test_logger::unset_file();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
use {
|
||||
std::{
|
||||
mem,
|
||||
rc::Rc,
|
||||
sync::{Arc, Condvar, Mutex},
|
||||
},
|
||||
parking_lot::{Condvar, Mutex},
|
||||
std::{mem, rc::Rc, sync::Arc},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
|
|
@ -21,15 +18,15 @@ impl FdCloser {
|
|||
let slf2 = slf.clone();
|
||||
std::thread::spawn(move || {
|
||||
let mut fds = vec![];
|
||||
let mut lock = slf2.fds.lock().unwrap();
|
||||
let mut lock = slf2.fds.lock();
|
||||
loop {
|
||||
mem::swap(&mut *lock, &mut fds);
|
||||
if fds.len() > 0 {
|
||||
drop(lock);
|
||||
fds.clear();
|
||||
lock = slf2.fds.lock().unwrap();
|
||||
lock = slf2.fds.lock();
|
||||
} else {
|
||||
lock = slf2.cv.wait(lock).unwrap();
|
||||
slf2.cv.wait(&mut lock);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -39,7 +36,7 @@ impl FdCloser {
|
|||
pub fn close(&self, fd: Rc<OwnedFd>) {
|
||||
match Rc::try_unwrap(fd) {
|
||||
Ok(fd) => {
|
||||
self.fds.lock().unwrap().push(fd);
|
||||
self.fds.lock().push(fd);
|
||||
self.cv.notify_all();
|
||||
}
|
||||
Err(_e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue