mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-23 00:00:10 +02:00
task: wake LocalSet on spawn_local (#3369)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user