Skip to content

Commit

Permalink
Make example more complete
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Nov 3, 2021
1 parent 97c4697 commit d1a7b26
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,31 @@ Threadfin supports asynchronous usage via futures, and allows you to mix and mat
## Examples

```rust
// Create a new pool.
let pool = threadfin::builder().size(8).build();

// Schedule some work.
let compute_task = pool.execute(|| {
// Some expensive computation
2 + 2
});

// Do something in the meantime.
println!("Waiting for result...");

// Wait for the task to complete and get the result.
let sum = compute_task.join();
println!("Sum: 2 + 2 = {}", sum);
```

## Installation

Install via Cargo by adding to your Cargo.toml file:

```toml
[dependencies]
threadfin = "0.1"
```

### Minimum supported Rust version

Expand Down
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,21 @@
//! ## Examples
//!
//! ```
//! // Create a new pool.
//! let pool = threadfin::builder().size(8).build();
//!
//! // Schedule some work.
//! let compute_task = pool.execute(|| {
//! // Some expensive computation
//! 2 + 2
//! });
//!
//! // Do something in the meantime.
//! println!("Waiting for result...");
//!
//! // Wait for the task to complete and get the result.
//! let sum = compute_task.join();
//! println!("Sum: 2 + 2 = {}", sum);
//! ```
mod common;
Expand Down

0 comments on commit d1a7b26

Please sign in to comment.