Redesign the whole interface
This commit is contained in:
parent
152afac61f
commit
a28a9643c9
21
Cargo.toml
21
Cargo.toml
|
@ -12,21 +12,14 @@ keywords = ["asynchronous", "executor", "single", "multi", "spawn"]
|
||||||
categories = ["asynchronous", "concurrency"]
|
categories = ["asynchronous", "concurrency"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["async-io"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures-lite = "0.1.8"
|
async-task = "3.0.0"
|
||||||
multitask = "0.2.0"
|
concurrent-queue = "1.2.2"
|
||||||
parking = "2.0.0"
|
fastrand = "1.3.4"
|
||||||
scoped-tls = "1.0.0"
|
futures-lite = "1.0.0"
|
||||||
waker-fn = "1.0.0"
|
once_cell = "1.4.1"
|
||||||
|
|
||||||
# Optional optimization: executor waits on I/O when idle.
|
|
||||||
[dependencies.async-io]
|
|
||||||
version = "0.1.5"
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
async-channel = "1.1.1"
|
async-channel = "1.4.1"
|
||||||
|
async-io = "0.2.0"
|
||||||
easy-parallel = "3.1.0"
|
easy-parallel = "3.1.0"
|
||||||
|
|
29
README.md
29
README.md
|
@ -9,31 +9,24 @@ https://crates.io/crates/async-executor)
|
||||||
[![Documentation](https://docs.rs/async-executor/badge.svg)](
|
[![Documentation](https://docs.rs/async-executor/badge.svg)](
|
||||||
https://docs.rs/async-executor)
|
https://docs.rs/async-executor)
|
||||||
|
|
||||||
Async executor.
|
Async executors.
|
||||||
|
|
||||||
This crate offers two kinds of executors: single-threaded and multi-threaded.
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
Run a single-threaded and a multi-threaded executor at the same time:
|
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use async_channel::unbounded;
|
use async_executor::Executor;
|
||||||
use async_executor::{Executor, LocalExecutor};
|
use futures_lite::future;
|
||||||
use easy_parallel::Parallel;
|
|
||||||
|
|
||||||
|
// Create a new executor.
|
||||||
let ex = Executor::new();
|
let ex = Executor::new();
|
||||||
let local_ex = LocalExecutor::new();
|
|
||||||
let (trigger, shutdown) = unbounded::<()>();
|
|
||||||
|
|
||||||
Parallel::new()
|
// Spawn a task.
|
||||||
// Run four executor threads.
|
let task = ex.spawn(async {
|
||||||
.each(0..4, |_| ex.run(shutdown.recv()))
|
println!("Hello world");
|
||||||
// Run local executor on the current thread.
|
});
|
||||||
.finish(|| local_ex.run(async {
|
|
||||||
println!("Hello world!");
|
// Run the executor until the task complets.
|
||||||
drop(trigger);
|
future::block_on(ex.run(task));
|
||||||
}));
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
881
src/lib.rs
881
src/lib.rs
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue