executor, threadpool: forward port fix from #1155 (#1433)

Add executor::exit, allowing other executors inside threadpool::blocking.
This commit is contained in:
Ilya Lakhin
2019-08-13 21:12:49 -07:00
committed by Carl Lerche
parent 517162792f
commit fb9809c068
4 changed files with 62 additions and 2 deletions
+20
View File
@@ -39,6 +39,26 @@ fn basic() {
rx2.recv().unwrap();
}
#[test]
fn other_executors_can_run_inside_blocking() {
let _ = ::env_logger::try_init();
let pool = Builder::new().pool_size(1).max_blocking(1).build();
let (tx, rx) = mpsc::channel();
pool.spawn(async move {
let res = blocking(|| {
let _e = tokio_executor::enter().expect("nested blocking enter");
tx.send(()).unwrap();
});
assert_ready!(res).unwrap();
});
rx.recv().unwrap();
}
#[test]
fn notify_task_on_capacity() {
const BLOCKING: usize = 10;