4 stable releases

1.3.0 Apr 2, 2021
1.2.0 Apr 2, 2021
1.1.0 Apr 1, 2021
1.0.0 Mar 27, 2021

#1899 in Asynchronous

Zlib OR MIT OR Apache-2.0

16KB
193 lines

entangled

Latest version Documentation ZLIB MIT Apache

Entangled provides a thread pool based on the async-executor crate to spawn async futures on.

It's main selling point is the "scoped spawn" functionality, which is essentially forking tasks from the main thread, which have access to the stack of the main thread and joins them after they have completed.

Example

use entangled::*;
use std::sync::atomic::*;

fn main() {
    let pool = ThreadPool::new(
        ThreadPoolDescriptor::default()
    ).expect("can't create task pool");

    let counter = AtomicI32::new(0);
    let ref_counter = &counter;

    pool.scope(|scope| {
        for _ in 0..10 {
            scope.spawn(async {
                ref_counter.fetch_add(1, Ordering::Relaxed);
            });
        }
    });

    assert_eq!(counter.load(Ordering::Relaxed), 10);
}

Credits

Originally based on bevy_tasks crate, but was completely rewritten with version 1.2

License

Licensed under Apache-2.0 or MIT or ZLIB.

Dependencies

~1MB
~16K SLoC