Skip to content

Commit

Permalink
Redesign the whole interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Stjepan Glavina committed Aug 26, 2020
1 parent 152afac commit a28a964
Show file tree
Hide file tree
Showing 3 changed files with 554 additions and 377 deletions.
21 changes: 7 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit a28a964

Please sign in to comment.