mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-07 00:00:09 +02:00
Merge tokio-1.44.1 into master (#7218)
This commit is contained in:
@@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
tokio = { version = "1.44.0", features = ["full"] }
|
||||
tokio = { version = "1.44.1", features = ["full"] }
|
||||
```
|
||||
Then, on your main.rs:
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# 1.44.1 (March 13th, 2025)
|
||||
|
||||
### Fixed
|
||||
|
||||
- rt: skip defer queue in `block_in_place` context ([#7216])
|
||||
|
||||
[#7216]: https://github.com/tokio-rs/tokio/pull/7216
|
||||
|
||||
# 1.44.0 (March 7th, 2025)
|
||||
|
||||
This release changes the `from_std` method on sockets to panic if a blocking
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ name = "tokio"
|
||||
# - README.md
|
||||
# - Update CHANGELOG.md.
|
||||
# - Create "v1.x.y" git tag.
|
||||
version = "1.44.0"
|
||||
version = "1.44.1"
|
||||
edition = "2021"
|
||||
rust-version = "1.70"
|
||||
authors = ["Tokio Contributors <[email protected]>"]
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
tokio = { version = "1.44.0", features = ["full"] }
|
||||
tokio = { version = "1.44.1", features = ["full"] }
|
||||
```
|
||||
Then, on your main.rs:
|
||||
|
||||
|
||||
@@ -782,7 +782,13 @@ impl Context {
|
||||
}
|
||||
|
||||
pub(crate) fn defer(&self, waker: &Waker) {
|
||||
self.defer.defer(waker);
|
||||
if self.core.borrow().is_none() {
|
||||
// If there is no core, then the worker is currently in a block_in_place. In this case,
|
||||
// we cannot use the defer queue as we aren't really in the current runtime.
|
||||
waker.wake_by_ref();
|
||||
} else {
|
||||
self.defer.defer(waker);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
||||
@@ -126,6 +126,17 @@ fn unbounded_mpsc_channel() {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn yield_in_block_in_place() {
|
||||
test_with_runtimes(|| {
|
||||
Handle::current().block_on(async {
|
||||
tokio::task::block_in_place(|| {
|
||||
Handle::current().block_on(tokio::task::yield_now());
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "wasi"))] // Wasi doesn't support file operations or bind
|
||||
rt_test! {
|
||||
use tokio::fs;
|
||||
|
||||
@@ -647,6 +647,51 @@ fn test_nested_block_in_place_with_block_on_between() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn yield_now_in_block_in_place() {
|
||||
let rt = runtime::Builder::new_multi_thread()
|
||||
.worker_threads(1)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
rt.block_on(async {
|
||||
tokio::spawn(async {
|
||||
tokio::task::block_in_place(|| {
|
||||
tokio::runtime::Handle::current().block_on(tokio::task::yield_now());
|
||||
})
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mutex_in_block_in_place() {
|
||||
const BUDGET: usize = 128;
|
||||
|
||||
let rt = runtime::Builder::new_multi_thread()
|
||||
.worker_threads(1)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
rt.block_on(async {
|
||||
let lock = tokio::sync::Mutex::new(0);
|
||||
|
||||
tokio::spawn(async move {
|
||||
tokio::task::block_in_place(|| {
|
||||
tokio::runtime::Handle::current().block_on(async move {
|
||||
for i in 0..(BUDGET + 1) {
|
||||
let mut guard = lock.lock().await;
|
||||
*guard = i;
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
})
|
||||
}
|
||||
|
||||
// Testing the tuning logic is tricky as it is inherently timing based, and more
|
||||
// of a heuristic than an exact behavior. This test checks that the interval
|
||||
// changes over time based on load factors. There are no assertions, completion
|
||||
|
||||
Reference in New Issue
Block a user