github tokio-rs/tokio tokio-0.2.2
Tokio v0.2.2

latest releases: tokio-util-0.7.11, tokio-1.37.0, tokio-test-0.4.4...
4 years ago

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).

Don't miss a new tokio release

NewReleases is sending notifications on new releases.