Crate entangled[][src]

Entangled is a simple threadpool with minimal dependencies. The main use case is a scoped fork-join, i.e. spawning tasks from a single thread and having that thread await the completion of those tasks. There are also utilities for generating the tasks from a slice of data.

This library makes no attempt to ensure fairness or ordering of spawned tasks.

This is a hard fork of the bevy_tasks crate, to further reduce dependencies and simplify the interface.

Example

let pool = entangled::TaskPool::default();

let count = std::sync::atomic::AtomicI32::new(0);
let ref_count = &count;

let output = pool.scope(|scope| {
    for _ in 0..100 {
        scope.spawn(async {
            ref_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
            1
        });
    }
});

assert_eq!(output.iter().sum::<i32>(), count.load(std::sync::atomic::Ordering::Relaxed));

Re-exports

pub use async_executor::Task;

Structs

Scope

Scopes the execution of tasks.

TaskPool

A thread pool for executing tasks.

TaskPoolDescriptor

Describes how a TaskPool should be created.

Traits

ParallelIterator

Closely emulates the std::iter::Iterator interface, but computes batches in parallel.

ParallelSlice

Helper functions to iterate over a slice in parallel.

ParallelSliceMut

Helper functions to iterate over a mutable slice in parallel.