task: wake LocalSet on spawn_local (#3369)

This commit is contained in:
Cameron
2021-01-09 11:46:51 +01:00
committed by GitHub
parent 2fe2f0401b
commit 22c27b9282
2 changed files with 15 additions and 0 deletions
+1
View File
@@ -283,6 +283,7 @@ impl LocalSet {
let future = crate::util::trace::task(future, "local");
let (task, handle) = unsafe { task::joinable_local(future) };
self.context.tasks.borrow_mut().queue.push_back(task);
self.context.shared.waker.wake();
handle
}
+14
View File
@@ -1,6 +1,11 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::{
future::{pending, ready},
FutureExt,
};
use tokio::runtime::{self, Runtime};
use tokio::sync::{mpsc, oneshot};
use tokio::task::{self, LocalSet};
@@ -486,6 +491,15 @@ async fn acquire_mutex_in_drop() {
drop(local);
}
#[tokio::test]
async fn spawn_wakes_localset() {
let local = LocalSet::new();
futures::select! {
_ = local.run_until(pending::<()>()).fuse() => unreachable!(),
ret = async { local.spawn_local(ready(())).await.unwrap()}.fuse() => ret
}
}
fn rt() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()