New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce the Tokio runtime: Reactor + Threadpool #141
d7dea3d
815eee5
4121146
d57db69
eb823f8
4b55003
d664b21
e4cfc5e
3b051bc
a366f7c
b2953f0
658afb8
76ce551
234558c
f4f4168
a4c6225
8480f11
607958f
b60bfb6
d9e6806
626a49e
53ad363
beaf747
9c6cd94
8f53991
753bce0
8188c4b
adfcf10
Diff settings
| @@ -23,20 +23,24 @@ keywords = ["io", "async", "non-blocking", "futures"] | ||
| members = [ | ||
| "./", | ||
| "tokio-executor", | ||
| "tokio-io", | ||
| "tokio-threadpool", | ||
| ] | ||
| [badges] | ||
| travis-ci = { repository = "tokio-rs/tokio" } | ||
| appveyor = { repository = "carllerche/tokio" } | ||
| [dependencies] | ||
| tokio-io = "0.1" | ||
Show comment
Hide comment
kpp
Contributor
|
||
| tokio-executor = { version = "0.1", path = "tokio-executor" } | ||
| tokio-threadpool = { version = "0.1", path = "tokio-threadpool" } | ||
| bytes = "0.4" | ||
| log = "0.4" | ||
| mio = "0.6.13" | ||
| slab = "0.4" | ||
| iovec = "0.1" | ||
| tokio-io = "0.1" | ||
| futures = "0.1.16" | ||
| [dev-dependencies] | ||
| @@ -55,28 +55,26 @@ pub fn main() { | ||
| println!("accept error = {:?}", err); | ||
| }); | ||
| println!("server running on localhost:6142"); | ||
| // This starts the `current_thread` executor. | ||
| // | ||
| // Executors are responsible for scheduling many asynchronous tasks, driving | ||
| // them to completion. There are a number of different executor | ||
| // implementations, each providing different scheduling characteristics. | ||
| // | ||
| // The `current_thread` executor multiplexes all scheduled tasks on the | ||
| // current thread. This means that spawned tasks are not required to | ||
| // implement `Send`. | ||
| current_thread::run(|_| { | ||
| // Now, the server task must be spawned. | ||
| // current thread. This means that spawned tasks must not implement `Send`. | ||
Show comment
Hide comment
stjepang
Collaborator
|
||
| // It's important to note that all futures / tasks are lazy. No work will | ||
| // happen unless they are spawned onto an executor. | ||
| // | ||
| // It's important to note that all futures / tasks are lazy. No work | ||
| // will happen unless they are spawned onto an executor. | ||
| current_thread::spawn(server); | ||
| println!("server running on localhost:6142"); | ||
| // The `current_thread::run` function will now block until *all* spawned | ||
| // tasks complete. | ||
| // The executor will start running the `server` task, which, in turn, spawns | ||
| // new tasks for each incoming connection. | ||
| // | ||
| // In our example, we have not defined a shutdown strategy, so | ||
| // this will block until `ctrl-c` is pressed at the terminal. | ||
| }); | ||
| // The `current_thread::block_on_all` function will block until *all* | ||
| // spawned tasks complete. | ||
| // | ||
| // In our example, we have not defined a shutdown strategy, so this will | ||
| // block until `ctrl-c` is pressed at the terminal. | ||
| current_thread::block_on_all(server).unwrap(); | ||
| } | ||
Why do you set path in
tokio-executorlikepath = "tokio-executor"but you gettokio-iofrom crates.io?