Skip to content

Releases: tokio-rs/tokio

Tokio v0.2.3

06 Dec 17:57
98c9a77
Compare
Choose a tag to compare

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 and AsyncWriteExt (#1863).
  • read_buf / write_buf for reading / writing Buf / 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 now Sync (#1888).
  • impl conversions between tokio::time::Instant and
    std::time::Instant (#1904).

Fixes

Tokio v0.2.2

29 Nov 19:18
Compare
Choose a tag to compare

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 and Builder::threaded_scheduler (#1858).

Added

  • impl Stream for signal::unix::Signal (#1849).
  • API docs for platform specific behavior of signal::ctrl_c and signal::unix::Signal (#1854).
  • API docs for signal::unix::Signal::{recv, poll_recv} and signal::windows::CtrlBreak::{recv, poll_recv} (#1854).
  • File::into_std and File::try_into_std methods (#1856).

Tokio v0.2.1

27 Nov 05:49
632ee50
Compare
Choose a tag to compare

Fixes

  • API docs for TcpListener::incoming, UnixListener::incoming (#1831).

Added

  • tokio::task::LocalSet provides a strategy for spawning !Send tasks (#1733).
  • export tokio::time::Elapsed (#1826).
  • impl AsRawFd, AsRawHandle for tokio::fs::File (#1827).

Tokio v0.2.0

26 Nov 18:14
a81e272
Compare
Choose a tag to compare

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 a JoinHandle.
  • 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 to tokio-util.

Removed

  • Standalone timer and net drivers are removed, use Runtime instead
  • current_thread runtime is removed, use tokio::runtime::Runtime with
    basic_scheduler instead.

v0.2.0-alpha.5

19 Sep 20:58
80ba2a4
Compare
Choose a tag to compare
v0.2.0-alpha.5 Pre-release
Pre-release

Changed

  • sync: rename Lock -> Mutex and make it more like std::sync::Mutex (#1573).
  • time: rename sleep to delay_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 for AsyncRead + 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> for Command (#1513).
  • tls: TlsStream::get_ref and TlsStream::get_mut (#1537).