summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index 527183182..dea5e534a 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -258,7 +258,6 @@ mod tests {
use deno::js_check;
use futures::future::lazy;
use std::sync::atomic::Ordering;
- use std::thread;
#[test]
fn execute_mod() {
@@ -379,14 +378,16 @@ mod tests {
let resource = worker.state.resource.clone();
let rid = resource.rid;
- tokio::spawn(lazy(move || {
- worker.then(move |r| -> Result<(), ()> {
+ let worker_future = worker
+ .then(move |r| -> Result<(), ()> {
resource.close();
println!("workers.rs after resource close");
js_check(r);
Ok(())
- })
- }));
+ }).shared();
+
+ let worker_future_ = worker_future.clone();
+ tokio::spawn(lazy(move || worker_future_.then(|_| Ok(()))));
assert_eq!(resources::get_type(rid), Some("worker".to_string()));
@@ -395,9 +396,7 @@ mod tests {
assert!(r.is_ok());
debug!("rid {:?}", rid);
- // TODO Need a way to get a future for when a resource closes.
- // For now, just sleep for a bit.
- thread::sleep(std::time::Duration::from_millis(1000));
+ worker_future.wait().unwrap();
assert_eq!(resources::get_type(rid), None);
})
}