Releases: tokio-rs/tokio
Tokio v0.2.3
Mostly a bug fix, doc improvement, and polish release. The biggest new addition are the new helpers to read and write integers. They are on AsyncReadExt
and AsyncWriteExt
and can make protocol encoding / decoding easier. For example, working with length delimited payloads might look like:
use tokio::io::{self, AsyncReadExt, AsyncWriteExt, BufStream};
use tokio::net::TcpStream;
async fn read_frame(src: &mut BufStream<TcpStream>) -> io::Result<Vec<u8>> {
let len = src.read_u32().await?;
let mut frame = vec![0; len as usize];
src.read_exact(&mut frame).await?;
Ok(frame)
}
async fn write_frame(dst: &mut BufStream<TcpStream>, frame: &[u8]) -> io::Result<()> {
dst.write_u32(frame.len() as u32).await?;
dst.write_all(frame).await?;
dst.flush().await?;
Ok(())
}
Added
- read / write integers using
AsyncReadExt
andAsyncWriteExt
(#1863). read_buf
/write_buf
for reading / writingBuf
/BufMut
(#1881).TcpStream::poll_peek
- pollable API for performing TCP peek (#1864).sync::oneshot::error::TryRecvError
provides variants to detect the error
kind (#1874).LocalSet::block_on
accepts!'static
task (#1882).task::JoinError
is nowSync
(#1888).- impl conversions between
tokio::time::Instant
and
std::time::Instant
(#1904).
Fixes
Tokio v0.2.2
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).
Tokio v0.2.1
Tokio v0.2.0
A major breaking change. Most implementation and APIs have changed one way or
another. This changelog entry contains a highlight
Changed
- APIs are updated to use
async / await
. - most
tokio-*
crates are collapsed into this crate. - Scheduler is rewritten.
tokio::spawn
returns aJoinHandle
.- A single I/O / timer is used per runtime.
- I/O driver uses a concurrent slab for allocating state.
- components are made available via feature flag.
- Use
bytes
0.5 tokio::codec
is moved totokio-util
.
Removed
- Standalone
timer
andnet
drivers are removed, useRuntime
instead current_thread
runtime is removed, usetokio::runtime::Runtime
with
basic_scheduler
instead.
v0.2.0-alpha.5
Changed
- sync: rename
Lock
->Mutex
and make it more likestd::sync::Mutex
(#1573). - time: rename
sleep
todelay_for
(#1518).
Fixed
- executor: shutdown blocking pool threads when idle (#1562, #1514).
- fs: propagate flush for stdout / stderr. (#1528).
- net: API documentation generation (#1575).
Added
- io: bring back generic
split
forAsyncRead + AsyncWrite
(#1521). - io: enable buffering both reads and writes on the same type (#1558).
- process: platform specific
Command
methods (#1516). - process: implement
From<std::process::Command>
forCommand
(#1513). - tls:
TlsStream::get_ref
andTlsStream::get_mut
(#1537).