Redesign the whole interface

This commit is contained in:
Stjepan Glavina 2020-08-26 23:46:09 +02:00
parent 152afac61f
commit a28a9643c9
3 changed files with 554 additions and 377 deletions

View File

@ -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"

View File

@ -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

File diff suppressed because it is too large Load Diff