tests: fix ol' forker dumping core in tests
This commit is contained in:
parent
3bd1813d50
commit
22b7fb2ced
5 changed files with 34 additions and 6 deletions
|
|
@ -7,7 +7,13 @@ use {
|
|||
async_engine::ae_task::Runnable,
|
||||
utils::{array, numcell::NumCell, syncqueue::SyncQueue},
|
||||
},
|
||||
std::{cell::RefCell, collections::VecDeque, future::Future, rc::Rc, task::Waker},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::VecDeque,
|
||||
future::Future,
|
||||
rc::Rc,
|
||||
task::Waker,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
|
|
@ -26,6 +32,7 @@ pub struct AsyncEngine {
|
|||
yields: SyncQueue<Waker>,
|
||||
stash: RefCell<VecDeque<Runnable>>,
|
||||
yield_stash: RefCell<VecDeque<Waker>>,
|
||||
stopped: Cell<bool>,
|
||||
}
|
||||
|
||||
impl AsyncEngine {
|
||||
|
|
@ -37,9 +44,14 @@ impl AsyncEngine {
|
|||
yields: Default::default(),
|
||||
stash: Default::default(),
|
||||
yield_stash: Default::default(),
|
||||
stopped: Cell::new(false),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn stop(&self) {
|
||||
self.stopped.set(true);
|
||||
}
|
||||
|
||||
pub fn clear(&self) {
|
||||
self.stash.borrow_mut().clear();
|
||||
self.yield_stash.borrow_mut().clear();
|
||||
|
|
@ -83,6 +95,9 @@ impl AsyncEngine {
|
|||
self.num_queued.fetch_sub(stash.len());
|
||||
for runnable in stash.drain(..) {
|
||||
runnable.run();
|
||||
if self.stopped.get() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.yields.swap(&mut *yield_stash);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue