mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00

This patch is an intial implementation of the Tokio runtime. The Tokio runtime provides an out of the box configuration for running I/O heavy asynchronous applications. As of now, the Tokio runtime is a combination of a work-stealing thread pool as well as a background reactor to drive I/O resources. This patch also includes tokio-executor, a hopefully short lived crate that is based on the futures 0.2 executor RFC. * Implement `Park` for `Reactor` This enables the reactor to be used as the thread parker for executors. This also adds an `Error` component to `Park`. With this change, a `Reactor` and a `CurrentThread` can be combined to achieve the capabilities of tokio-core.
22 lines
450 B
Rust
22 lines
450 B
Rust
extern crate futures;
|
|
extern crate tokio_threadpool;
|
|
extern crate env_logger;
|
|
|
|
use tokio_threadpool::*;
|
|
use futures::*;
|
|
use futures::sync::oneshot;
|
|
|
|
pub fn main() {
|
|
let _ = ::env_logger::init();
|
|
|
|
let pool = ThreadPool::new();
|
|
let tx = pool.sender().clone();
|
|
|
|
let res = oneshot::spawn(future::lazy(|| {
|
|
println!("Running on the pool");
|
|
Ok::<_, ()>("complete")
|
|
}), &tx);
|
|
|
|
println!("Result: {:?}", res.wait());
|
|
}
|