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