Tokio v0.2.2
carllerche
released this
29 Nov 19:18
·
2398 commits
to master
since this release
Primarily a release fix for basic_scheduler
and task::LocalSet
.
task::LocalSet
was introduced in v0.2.1 and provides tooling to run !Send
tasks. The task::LocalSet
structure replaces the need to have separate runtimes. The advantage being that it can be used with the threaded runtime in order to run both Send
futures across multiple threads and !Send
futures on the current thread.
use tokio::runtime::Runtime;
use tokio::task;
use std::rc::Rc;
let unsend_data = Rc::new("my unsend data...");
let mut rt = Runtime::new().unwrap();
// Construct a local task set that can run `!Send` futures.
let local = task::LocalSet::new();
// Run the local task group.
local.block_on(&mut rt, async move {
let unsend_data = unsend_data.clone();
// `spawn_local` ensures that the future is spawned on the local
// task group.
task::spawn_local(async move {
println!("{}", unsend_data);
// ...
}).await.unwrap();
});
Fixes
- scheduling with
basic_scheduler
(#1861). - update
spawn
panic message to specify that a task scheduler is required (#1839). - API docs example for
runtime::Builder
to include a task scheduler (#1841). - general documentation (#1834).
- building on illumos/solaris (#1772).
- panic when dropping
LocalSet
(#1843). - API docs mention the required Cargo features for
Builder::basic_scheduler
andBuilder::threaded_scheduler
(#1858).
Added
- impl
Stream
forsignal::unix::Signal
(#1849). - API docs for platform specific behavior of
signal::ctrl_c
andsignal::unix::Signal
(#1854). - API docs for
signal::unix::Signal::{recv, poll_recv}
andsignal::windows::CtrlBreak::{recv, poll_recv}
(#1854). File::into_std
andFile::try_into_std
methods (#1856).