Crates.io | entangled |
lib.rs | entangled |
version | 1.3.0 |
source | src |
created_at | 2021-03-27 10:40:17.941395 |
updated_at | 2021-04-02 18:37:22.899632 |
description | A simple fork-join task executor. |
homepage | https://github.com/hasenbanck/entangled |
repository | https://github.com/hasenbanck/entangled |
max_upload_size | |
id | 374169 |
size | 33,558 |
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.
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);
}
Originally based on bevy_tasks crate, but was completely rewritten with version 1.2
Licensed under Apache-2.0 or MIT or ZLIB.